BookmarkSubscribeRSS Feed
teja5959
Obsidian | Level 7


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;

1 REPLY 1
ballardw
Super User

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?

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 583 views
  • 0 likes
  • 2 in conversation