BookmarkSubscribeRSS Feed
gzr2mz39
Quartz | Level 8

I have 10 questions from a survey. Each question has possible values 1-5.

I would like to create the following subscale averages:

questions 1, 2

questions 3, 4, 5

questions 6, 7, 8, 9

questions 10

So, this means there would be a total of 4 means (mean1, mean2, mean3, mean4).

Does anyone know how to do this with proc sql?

Thank you.

2 REPLIES 2
FriedEgg
SAS Employee

data foo;

call streaminit(12345);

array q[10];

do id=1 to 100;

  do i=1 to 10;

   q=abs(mod(int(rand('CAUCHY')*10),10));

  end;

  output;

end;

drop i;

run;

proc sql;

select avg(q1+q2)/2 as avg1, avg(q3+q4+q5)/3 as avg2, avg(q6+q7+q8+q9)/4 as avg3, avg(q10) as avg4  from foo;

quit;

Ksharp
Super User

What does your data look like? and what output do you want?

Ksharp

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 984 views
  • 3 likes
  • 3 in conversation