BookmarkSubscribeRSS Feed
jporterf
Fluorite | Level 6

Hello! I hope my title makes sense.

 

So here is the output data set I have for one of my data sets:

               

 Var1 Var2 Var3   Var4
01JAN2010Height 1111-11-1111
01JAN2010Weight2111-11-1111
01JAN2010Systolic BP3111-11-1111
01JAN2010Diastolic BP4111-11-1111
06JAN2011Height 5111-11-1111
06JAN2011Weight 6111-11-1111
06JAN2011Systolic BP7111-11-1111
06JAN2011Diastolic BP8111-11-1111

 

Here is what I need it to look like (this is a separate output data set I've already completed):

                     

 Var1 Var2Var3 Var4 Var5Var6
111-11-111130AUG20101111
111-11-111122AUG20112222
111-11-111131AUG20123333
111-11-111105SEP20134444
111-11-111112SEP20145555


I need each subject to have 4 observations organized by visit date, height, weight, SBP, and DBP. Currently, in the first data set, each subject has 16 observations. The variables currently include height, weight, SBP, DBP, and the values for each, and I need each of those to be their own variable and value. And then I need only 1 observation for each date for each SSN instead of 4 observations for each date and SSN.

 

I'm honestly not sure where to even begin. If I can get some guidance (even if it's just what functions to look into myself) I would greatly appreciate it!

5 REPLIES 5
PGStats
Opal | Level 21

Pre process your Measure field to transform the measure names into your expected variable names

 

if measure = 'Height (In)' then varname = "HtIn";

...

etc.

 

Then you can simply sort and transpose your dataset

 

proc sort ...; by SSN VisitDT;

 

proc transpose ... ;

by SSN VisitDt;

ID varname;

var value;

 

PG
PaigeMiller
Diamond | Level 26

Please clarify something. Is the desired output a table that you can e-mail or put in a report? Or is the desired output a SAS data set?


Either way, do not try doing this in a SAS data step. Either PROC REPORT or PROC TRANSPOSE will be the easiest solution.

--
Paige Miller
jporterf
Fluorite | Level 6

The desired output is SAS data set. I need to combine this data set with two other ones to create a final data set.

jporterf
Fluorite | Level 6

I thought this might deal with re-structuring data, thank you!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 1317 views
  • 3 likes
  • 4 in conversation