BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
EpiNovice
Calcite | Level 5

Good morning, I need help with code to create a variable that is the mean of a series of values from a long data set. For example, the data I have looks like this:

IDEventTime (ms)
1A1.2
1B3.3
1A1.1
1B2.3
1A0.9
1B1.9
1A1.4
2A2.3
2B3.2
2A1.9
2B2.8
2A1.7
2B3.1

 

And what I need is data that looks like this:

 

IDEventMean time (ms)
1A1.14
1B2.43
2A1.95
2B3.03

 

Do I need to reformat to wide dataset to accomplish this, or is there another way?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ
PROC MEANS DATA=HAVE MEAN NWAY;
 CLASS ID EVENT;
 VAR TIME;
 output out=work.ContainsMean mean= / autoname;
RUN;

Koen

View solution in original post

1 REPLY 1
sbxkoenk
SAS Super FREQ
PROC MEANS DATA=HAVE MEAN NWAY;
 CLASS ID EVENT;
 VAR TIME;
 output out=work.ContainsMean mean= / autoname;
RUN;

Koen

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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