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.
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.
Can you provide sample data as text please, not an image?
Preferably as a data step following the guidelines here:
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.
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.
Can you provide sample data as text please, not an image?
Preferably as a data step following the guidelines here:
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.
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.
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!
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.