Help using Base SAS procedures

Data Tagging across time

Reply
N/A
Posts: 1

Data Tagging across time

How do I create a tagging (DelinquentTag) variable based on that 3 variables across time.    

Example:

Data:

Date               Accno     Delinquent       DelinquentTag

30Nov2011     123          0                    N

31Dec2011     123          1                    Y

31Jan2012      123          0                    Y

30Nov2011     234          0                    N

31Dec2011     234          0                    N

30Nov2011     235          1                    Y

31Dec2011     235          1                    Y

Regards,

xchoit

Super User
Posts: 5,441

Re: Data Tagging across time

Do you want to mark all roes (for each accno) as "Y" from the record where delinquent is = 1, and thereafter?

You could archive this by using first.-logic together with the retain statement.

Data never sleeps
Respected Advisor
Posts: 3,799

Re: Data Tagging across time

Once the acc becomes delinquent stop checking and "retain" true.

data acc;
   input Date:date. Accno:$3. Delinquent;
   format date date9.;
  
cards;
30Nov2011     123          0              
31Dec2011     123          1              
31Jan2012      123          0             
30Nov2011     234          0              
31Dec2011     234          0              
30Nov2011     235          1              
31Dec2011     235          1              
;;;;
   run;
data deliq;
   flag = 0;
  
do until(last.accno);
      set acc;
      by accno;
      if not flag then flag = ifn(Delinquent,1,0);
      output;
     
end;
  
run;
Ask a Question
Discussion stats
  • 2 replies
  • 143 views
  • 0 likes
  • 3 in conversation