Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

First. and Last.

Status
Not open for further replies.

shenniko

Programmer
Apr 15, 2005
52
US
Hi guys,

Need some of your expert wisdom! :)

This is the first time im using the First. and Last. and im having a little trouble...

Ive the following code below:-

Code:
Data Telco_Features_By;
	set Telco_Features_Raw;
	By Workorder;

	retain last_Act_date MyCount;

	if (first.Workorder) then
		do;
			MyCount=1;
			if ((DATE_ACTIONED le &end_dat.) and (DATE_ACTIONED ne .)) then
				last_Act_date=DATE_ACTIONED;
		end;
	else if (WO_ENTRY_DATE ge last_Act_date) then
		do;
			if (last_Act_date ne .) then
				if (intck('DAY',last_Act_date,WO_ENTRY_DATE) le 1) then
						MyCount+1;
			else
				last_Act_date=.;
	end;
Format last_Act_date date9.;
run;

Basically the above code will find duplicate account numbers.. So people who have called us more than once.. but what i need is some code to identify if the customer has called 3 or more times..

So if they call twice, then dont display that data.. If they have called 3 or more times, then display that data...

any ideas?

Thanks in advance

Shenn
 
Hi Shenn,

I havent gone thru it fully, but on first thought, how abt placing the entire if..else if...end segment within a if stmt like this:

if MyCount ge 3 then do;
if (first.Workorder) then
do;
MyCount=1;
if ((DATE_ACTIONED le &end_dat.) and
(DATE_ACTIONED ne .)) then
last_Act_date=DATE_ACTIONED;
end;
else if (WO_ENTRY_DATE ge last_Act_date) then
do;
if (last_Act_date ne .) then
if (intck('DAY',last_Act_date,WO_ENTRY_DATE) le 1) then
MyCount+1;
else
last_Act_date=.;
end;
end;
 
Sarav - Wouldn't work, the counter MyCount would never be incremented because it's inside the check to see if it is greater than 3, which it never will be.

Shenniko - I reckon you've probably solved this one by now, it's a pretty straightforward problem, just need to break it down in stages. Do the count, then check to see if you have a count greater than 3. I always advise doing these things by steps as it makes it a hell of alot easier to test as you go, you can then check the results after each step to make sure you're getting what you expect, then work out how to react to that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top