data have;
infile datalines dsd truncover;
input subjid $ visitnum $ armcd $;
datalines;
101,1,height
101,1,weight
101,1,bmi
101,1,temp
101,2,temp
101,3,temp
101,4,temp
101,5,temp
101,1,hr
101,2,hr
101,3,hr
101,4,hr
101,5,hr
102,1,height
102,1,weight
102,1,bmi
102,1,temp
102,3,temp
102,4,temp
102,5,temp
103,1,height
103,1,weight
103,1,bmi
103,3,temp
103,4,temp
103,6,temp
104,1,hr
104,3,hr
104,4,hr
104,5,hr
105,1,temp
105,3,temp
105,5,temp
106,1,height
106,1,weight
106,1,bmi
106,1,temp
;
run;
how to get this data using above data set
data want;
infile datalines dsd truncover;
input subjid $ visitnum $ armcd $ AVISITN;
datalines;
101,1,height,1
101,1,weight,1
101,1,bmi,1
101,1,temp,,
101,2,temp,1
101,3,temp,3
101,4,temp,4
101,5,temp,5
101,1,hr,,
101,2,hr,1
101,3,hr,3
101,4,hr,4
101,5,hr,5
102,1,height,1
102,1,weight,1
102,1,bmi,1
102,1,temp,1
102,3,temp,3
102,4,temp,4
102,5,temp,5
103,1,height,1
103,1,weight,1
103,1,bmi,1
103,3,temp,3
103,4,temp,4
103,6,temp,6
104,1,hr,,
104,3,hr,3
104,4,hr,4
104,5,hr,5
105,1,temp,1
105,3,temp,3
105,5,temp,5
106,1,height,,
106,1,weight,,
106,1,bmi,,
106,1,temp,,
;
run;
Define what "first IP administration" is or how we can tell in the data that occurs. I hate to guess and since there is no Variable named either IP or Administration or anything resembling either of those words that is what I would be doing.
It appears like a "find the value per Subjid (NOT mentioned in your request) and merge that value back onto the whole data set by subjid.
One potential problem, what if there is break in the data, such as long interval related to whatever this activity is, and the same subjid reappears later and should not be treated as the same sequence of visits?
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!
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.