data AE;
input PT @7 TERM$ @18 START yymmdd10. @32 RFSTDTC yymmdd10. @46 AESTDY;
format START RFSTDTC yymmdd10.;
cards;
101 HEADACHE 2014-02-13 2014-02-14 -1
101 VOMITING 2014-02-10 2014-02-14 -4
101 BACK PAIN 2014-03-12 2014-02-14 26
102 HEADACHE 2014-02-13 2014-02-08 5
102 VOMITING 2014-02-10 2014-02-08 2
103 HEADACHE 2014-02-13 2014-02-10 3
103 VOMITING 2014-02-10 2014-02-10 0
103 BACK PAIN 2014-03-12 2014-02-10 30
103 FEVER 2014-04-13 2014-02-10 62
;
run;
output
------------------------
PT TERM START RFSTDTC AEENRTPT AESTDY
101 HEADACHE 2014-02-13 2014-02-14 Before -1
101 VOMITING 2014-02-10 2014-02-14 Before -4
101 BACK PAIN 2014-03-12 2014-02-14 After 26
102 HEADACHE 2014-02-13 2014-02-08 After 5
102 VOMITING 2014-02-10 2014-02-08 After 2
103 HEADACHE 2014-02-13 2014-02-10 After 3
103 VOMITING 2014-02-10 2014-02-10 After 0
103 BACK PAIN 2014-03-12 2014-02-10 After 30
103 FEVER 2014-04-13 2014-02-10 After 62
Then you need an if statement as there is three options:
data want; set ae; if aestdy < 0 then aeenrtpt="Before";
else if aestdy=0 then aeenrtpt="Conicident";
else aeenrtpt="After"; run;
Something like:
data want; set ae; aeenrtpt=ifc(aestdy <0,"Before","After"); run;
Then you need an if statement as there is three options:
data want; set ae; if aestdy < 0 then aeenrtpt="Before";
else if aestdy=0 then aeenrtpt="Conicident";
else aeenrtpt="After"; run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.