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
Thanks in advance !
where is your sample data and the final output you need ?
Do you mind to use proc tabulate or proc report ?
Ksharp
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
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 !
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
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!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.