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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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