Help using Base SAS procedures

Proc Freq or Proc Summary

Reply
Regular Contributor
Posts: 183

Proc Freq or Proc Summary

Hi Everyone,

I have a datafile containing survey responses with demographics. Let's say, 10 questions (Q1-Q10) and 3 demographics ( Age, Gender and Experience). All questions are six-point scale questions. That means 6 choices in multiple choice questions.

I want to calculate count percentage of 5 and 6 for each questions by Age demographic. Age demog contains 5 options. I used Proc Freq statement but it doesn't allow me to break question frequency by Age. And i didn't find any option for count percentage in Proc MEANS or Proc SUMMARY.

Is it possible to accomplish this using Proc SUMMARY?? I don't want to use PROC SQL for this as i am learning SAS Base Smiley Wink

Thanks in advance !

Super User
Posts: 10,028

Re: Proc Freq or Proc Summary

where is your sample data and the final output you need ?

Do you mind to use proc tabulate or proc report ?

Ksharp

Super User
Posts: 10,028

Re: Proc Freq or Proc Summary

data have;
input age q1 q2;
cards;
12 1 2
12 6 5
12 5 6
12 2 6
22 6 2
22 2 5
22 5 6
22 5 6
;
run;
data temp(drop=i q:);
 set have;
 array x{*} q: ;
 do i=1 to dim(x);
  name=vname(x{i});value=x{i};output;
 end;
run;
proc sort data=temp;
 by age name value;
run;
proc freq noprint;
table age*name*value/list out=want(where=(value in (5 6))) nocum;
run;

Ksharp

Regular Contributor
Posts: 183

Re: Proc Freq or Proc Summary

Hi KSharp,

Thank you very much for writing the code.

It is generating count percentage of 5 or 6 separately. I am looking for the combined percentage of 5 and 6.

Thanks once again !

Super User
Posts: 10,028

Re: Proc Freq or Proc Summary

use proc format.

data have;
input age q1 q2;
cards;
12 1 2
12 6 5
12 5 6
12 2 6
22 6 2
22 2 5
22 5 6
22 5 6
;
run;
data temp(drop=i q:);
 set have;
 array x{*} q: ;
 do i=1 to dim(x);
  name=vname(x{i});value=x{i};output;
 end;
run;
proc sort data=temp;
 by age name value;
run;





proc format;
value fmt
  5,6='5 and 6';
run;

proc freq noprint;
table age*name*value/list out=want(where=(value in (5 6))) nocum;
format value fmt.;
run;




Ksharp

Ask a Question
Discussion stats
  • 4 replies
  • 244 views
  • 2 likes
  • 2 in conversation