ID | Date | Glucose_elev | Gluose_historical |
1 | Jan-12 | 0 | 0 |
1 | Mar-12 | 0 | 0 |
1 | Oct-13 | 1 | 1 |
1 | Feb-14 | 0 | 1 |
1 | Jul-15 | 1 | 1 |
2 | Feb-12 | 1 | 1 |
2 | May-13 | 1 | 1 |
2 | May-15 | 1 | 1 |
2 | May-16 | 1 | 1 |
3 | Jan-12 | 0 | 0 |
3 | Feb-13 | 1 | 1 |
3 | Jun-13 | 0 | 1 |
3 | Feb-14 | 0 | 1 |
3 | May-15 | 0 | 1 |
3 | Nov-15 | 1 | 1 |
3 | Dec-15 | 1 | 1 |
3 | Dec-15 | 0 | 1 |
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
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;
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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.