Getting/creating new summary variables longitudinal data

Reply
Contributor
Posts: 21

Getting/creating new summary variables longitudinal data

Hello,

 

I have a longitudinal dataset with various features. I want to create a newdataset that is not longitudinal and has new variables that represent the mean, median, and variance measures for each feature by ID!

 

Data Have: 

ID          feature1         feature2         feature3

1               7.72               5.43              4.35

1               5.54               2.25              8.22 

1               4.43               6.75              2.22

1               3.22               3.21              7.31

2               6.72               2.86              6.11

2               5.89               4.25              5.25 

2               3.43               7.30              8.21

2               1.22               3.55              6.55

 

Data Want:

ID                 Meanfeature1       Medianfeature1      variancefeature1   Meanfeature2       Medianfeature2      variancefeature2.........        

1

2

 

Any advice on the code?

 

Thanks!

 

 

 

Super User
Posts: 17,907

Re: Getting/creating new summary variables longitudinal data

PROC MEANS

Contributor
Posts: 21

Re: Getting/creating new summary variables longitudinal data

thanks, yes I know proc means gives you the summary statistics and you can get the mean, median and variance.

but I want to generate a whole new dataset showcasing the mean, median, and variance for each feature by ID...

 

Super User
Posts: 17,907

Re: Getting/creating new summary variables longitudinal data

PROC MEANS

 

What part of PROC MEANS doesn't do what you want?

Super User
Posts: 17,907

Re: Getting/creating new summary variables longitudinal data

[ Edited ]

I wasn't being snarky by the way (though I often am Smiley Happy). 

 

PROC MEANS is really what you seem to be asking for based on the output. You can merge this back in with your main dataset if you want. You could also use SQL if you wanted this in a single dataset with your original data but MEDIAN wasn't supported in SQL until SAS 9.4 and not everyone is on that system. Plus it generates warnings in the logs that users don't seem to like. 

 

DELETE_proc_means.JPG

Contributor
Posts: 21

Re: Getting/creating new summary variables longitudinal data

Thanks! no worries. you just answered my question. I was wondering if there was another way of getting the median etc and variance directly....

 

 

Super User
Posts: 10,538

Re: Getting/creating new summary variables longitudinal data


Jest wrote:

Thanks! no worries. you just answered my question. I was wondering if there was another way of getting the median etc and variance directly....

 

 


What would "directly" mean in this context? Just curious but I see a number of cases where people try to do in a data step what the SAS procedures are intended to accomplish. Often there is much anguish (and often ugly code) trying to replace a 3 or 4 line call to proc means/ summary /univariate or other proc.

Valued Guide
Posts: 2,175

Re: Getting/creating new summary variables longitudinal data

Would the Univariate Procedure offer another way?
Ask a Question
Discussion stats
  • 7 replies
  • 139 views
  • 0 likes
  • 4 in conversation