BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
keherder
Obsidian | Level 7

Hello everyone!

So, this is nothing I've tried to do before, so I'm not sure where to start. 

 

I am looking at simulated clinical trial data. Each participant was examined 3-5 times on different dates. The dates are different for each participant.  and I would like to create a numeric variable in a data step that corresponds to dates chronologically as baseline (1), 1st follow up (2), 2nd follow up (3), etc. 

 

Data set. As you can see, all participants were examined multiple times on different datesData set. As you can see, all participants were examined multiple times on different dates Above is a photo of the data. I would like to create this variable so that I can transpose the data so each participant has only one observation with a baseline BMI and all other values at baseline, 1st follow up, 2nd follow up, etc. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Can you provide sample data as text please, not an image?

Preferably as a data step following the guidelines here:

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 

How are missing visits identified? Are they missing as in row 6, or excluded as in Case 1488 that has only 5 records? If it's excluded how do you know which visit was excluded? Is it by the duration between visits, or last visit, or some other logic?

 

Given this as your input, please show what you would like as the output. 

Also, why do you think you need to do this overall. There's a reason data sets are stored this way 🙂

And SAS can usually do the analysis with the data in this form. 

 

Here are some references that may be useful:

 

How to create a counter variable

https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/

 

Transposing data tutorials:
Long to Wide:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/

https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/



@keherder wrote:

Hello everyone!

So, this is nothing I've tried to do before, so I'm not sure where to start. 

 

I am looking at simulated clinical trial data. Each participant was examined 3-5 times on different dates. The dates are different for each participant.  and I would like to create a numeric variable in a data step that corresponds to dates chronologically as baseline (1), 1st follow up (2), 2nd follow up (3), etc. 

 

Data set. As you can see, all participants were examined multiple times on different datesData set. As you can see, all participants were examined multiple times on different dates Above is a photo of the data. I would like to create this variable so that I can transpose the data so each participant has only one observation with a baseline BMI and all other values at baseline, 1st follow up, 2nd follow up, etc. 

 

 





View solution in original post

2 REPLIES 2
Reeza
Super User

Can you provide sample data as text please, not an image?

Preferably as a data step following the guidelines here:

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 

How are missing visits identified? Are they missing as in row 6, or excluded as in Case 1488 that has only 5 records? If it's excluded how do you know which visit was excluded? Is it by the duration between visits, or last visit, or some other logic?

 

Given this as your input, please show what you would like as the output. 

Also, why do you think you need to do this overall. There's a reason data sets are stored this way 🙂

And SAS can usually do the analysis with the data in this form. 

 

Here are some references that may be useful:

 

How to create a counter variable

https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/

 

Transposing data tutorials:
Long to Wide:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/

https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/



@keherder wrote:

Hello everyone!

So, this is nothing I've tried to do before, so I'm not sure where to start. 

 

I am looking at simulated clinical trial data. Each participant was examined 3-5 times on different dates. The dates are different for each participant.  and I would like to create a numeric variable in a data step that corresponds to dates chronologically as baseline (1), 1st follow up (2), 2nd follow up (3), etc. 

 

Data set. As you can see, all participants were examined multiple times on different datesData set. As you can see, all participants were examined multiple times on different dates Above is a photo of the data. I would like to create this variable so that I can transpose the data so each participant has only one observation with a baseline BMI and all other values at baseline, 1st follow up, 2nd follow up, etc. 

 

 





keherder
Obsidian | Level 7
Ahh, perfect! I was overcomplicating things, all I needed was a count variable. Thank you so much, Reeza!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 917 views
  • 0 likes
  • 2 in conversation