Hi All,
I need frequency matrix of my data.
my data is having 3 question Q1 -- Q23 and and one variable is cluster
value of cluster is 1 to 3
and values of Q1--Q23 are 1 to 5
i am using code below:
proc freq data=out_3 ;
table (Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12 Q13 Q14 Q15 Q16 Q17 Q18 Q19 Q20 Q21 Q22 Q23)*cluster
/nocol norow nocum nopercent;
run;
OUTPUT:
Q23 CLUSTER COUNT PERCENT
1 1 68 0.3046322014
1 2 698 3.1269599498
1 3 3310 14.828420392
2 1 213 0.9542155721
2 2 2114 9.4704775558
2 3 3598 16.118627363
3 1 1323 5.9268882717
3 2 4657 20.862825912
3 3 1015 4.5470835947
4 1 3314 14.846339934
4 2 1385 6.2046411612
4 3 42 0.1881551832
5 1 472 2.1145058686
5 2 103 0.4614281874
5 3 10 0.0447988531
Now problem is , i am getting output only for Q23 , but i am looking result for all Q1--23 .
Is it possible to get that.
Thanks in advance
Could you please supply some test data in a data step (w/ cards) so we have something to chew on?
PS you added "nopercent" for the tables, yet your example output shows a percent column.
Are you sure this is the output of your code?
proc freq data=out_3 ; table (Q1-Q23)*cluster /nocol norow nocum nopercent list out=want ; run;
Out of interest, does the : work there also?:
proc freq data=out_3; table (Q:)*cluster /nocol norow nocum nopercent list out=want; run;
Yes, @RW9, the colon notation works in this case too. At least within SAS 9.3 and later, where I tested.
Example:
proc freq data=sashelp.baseball;
table (D:)*position;
run;
Matches DIVISION and DIV (two different fields).
sir i have already run these code, but in output want , i m getting only result for Q23. please check the output.
Read the documentation. And I mean it.
Only the last table will end up in the output dataset. SAS works as documented in this case.
Try transposing your dataset, so that you can use question number as a by variable.
I guess you just need to read the documentation thoroughly
From PROC FREQ - TABLES Statement:
OUT=SAS-data-set
names an output data set that contains frequency or crosstabulation table counts and percentages. If more than one table request appears in the TABLES statement, the contents of the OUT= data set correspond to the last table request in the TABLES statement.
(Underline added by me)
ods output list=want; proc freq data=out_3 ; table (Q1-Q23)*cluster /nocol norow nocum nopercent list ; run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.