BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
wwjsun
Calcite | Level 5
ID Date Glucose_elevGluose_historical
1Jan-1200
1Mar-1200
1Oct-1311
1Feb-1401
1Jul-1511
2Feb-1211
2May-1311
2May-1511
2May-1611
3Jan-1200
3Feb-1311
3Jun-1301
3Feb-1401
3May-1501
3Nov-1511
3Dec-1511
3Dec-1501

 

I'm working on a dataset contains multiple subjects' longitudinal glucose level.  A typical scenario is, a high-risk patients' glucose level maintain normal until it reached the level of diabetics stage (Glucose_elev=1). Once the event triggered, even afterward his blood glucose went under control by medicine (Glucose_elve=0), we still consider this individual as "diabetic" (Glocuse_historical=1) after initial trigger event and ever after.  Some of the patients may never reach to diabetics stage during the study; others may be diabetic all the way, like subject #2. 

 

I would like to know how to code for Glucose_historical value. For one subject, before the trigger event, Glucose_histroical= 0, and on and after the trigger event, Glucose_historical=1. 

 

Thanks a million

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

try next code:

 

data want;

 set have;

  by ID;

        retain glucode_historical;

       if first.id then glucose_historical=0;

       if glucose_elev=1 then glucose_historical=1;

 run;

View solution in original post

2 REPLIES 2
Shmuel
Garnet | Level 18

try next code:

 

data want;

 set have;

  by ID;

        retain glucode_historical;

       if first.id then glucose_historical=0;

       if glucose_elev=1 then glucose_historical=1;

 run;

wwjsun
Calcite | Level 5
Absolutely! Thanks so much, Shmuel!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 800 views
  • 1 like
  • 2 in conversation