BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zaara
Calcite | Level 5

 

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

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Something like:

data want;
  set ae;
  aeenrtpt=ifc(aestdy <0,"Before","After");
run;
zaara
Calcite | Level 5
what if i need as 'Concident' for 0(zero) ??
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 866 views
  • 0 likes
  • 2 in conversation