AHMED@PANAM.BITNET (Zulfi Ahmed, Tr. & Supp. Specialist) (02/08/90)
Hi folks, I have survey data that was distributed to different classes. The survey record itself has the class number and 10 questions with answers ranging from 1 to 5. **************************************** section q1 q2 q3 q4 q5 q6 q7 q8 q9 q10 =>This line is not in the data file 1111 1 1 1 2 3 4 5 5 3 3 2222 2 3 4 5 2 1 1 1 1 3 . . 1111 1 1 1 1 3 4 2 3 4 1 *************************************** I need to determine the frequency of answers to each question by class, i.e, I would llike a report for each class on a separate page with Q!-Q10 going down vertically, and frequency of ocuurrence of the choices going horizontally. Following is a desired format. SECTION 1111 1 2 3 4 5 __________________________ Q1 20 13 11 11 10 Q2 . Q3 . . . . . Q10 . __________________________ I have used the following which gives me a report of frquency by each class but it is not in the format I want: ************************************************************* PROC TABULATE; CLASS SECTION Q1-Q10 MISSING F=8.2; TABLE (Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10)*(N)/RTS=12 CONDENSE; BY CLASS; ************************************************************* I have racked my brains with the PROC TABULATE section of the manual without luck. Any help would be appreciated.
HIS@NIHCU.BITNET (Howard Schreier) (02/08/90)
> Hi folks, I have survey data that was distributed to different classes. The > survey record itself has the class number and 10 questions with answers > ranging from 1 to 5. > > **************************************** > section q1 q2 q3 q4 q5 q6 q7 q8 q9 q10 =>This line is not in the data file > 1111 1 1 1 2 3 4 5 5 3 3 > 2222 2 3 4 5 2 1 1 1 1 3 > . > . > 1111 1 1 1 1 3 4 2 3 4 1 > *************************************** > > I need to determine the frequency of answers to each question by class, i.e, > I would llike a report for each class on a separate page with Q!-Q10 going > down vertically, and frequency of ocuurrence of the choices going horizontally > Following is a desired format. > > SECTION 1111 > 1 2 3 4 5 > __________________________ > Q1 20 13 11 11 10 > Q2 . > Q3 . > . . > . . > Q10 . > __________________________ > > > I have used the following which gives me a report of frquency by each class > but it is not in the format I want: > ************************************************************* > PROC TABULATE; > CLASS SECTION Q1-Q10 MISSING F=8.2; > TABLE (Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10)*(N)/RTS=12 CONDENSE; > BY CLASS; > ************************************************************* > > > I have racked my brains with the PROC TABULATE section of the manual without > luck. Any help would be appreciated. I think the problem is that the table you want requires "crossing" an additional CLASS variable which you do not have in your data set. The only way I see to get the job done is to transpose the data a bit before getting into PROC TABULATE. This seems to work: data try; input section q1-q10; array q(*) q1-q10; do qnum = 1 to dim(q); response = q(qnum); output; keep section qnum response; end; cards; 1111 1 1 1 2 3 4 5 5 3 3 2222 2 3 4 5 2 1 1 1 1 3 1111 1 1 1 1 3 4 2 3 4 1 ; proc tabulate; class section qnum response; table section,qnum,response*n*format=4.; Notice that the creation of a separate page for each section is done within the TABLE statement, so that BY processing is not necessary. For anyone who is going to use PROC TABULATE, I recommend getting and using SAS Guide to TABULATE Processing, 1987 Edition. It gives newer and more extensive documentation. /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \ Howard Schreier, U.S. Dept. of Commerce, Washington / | (Using Version 5 under IBM OS MVS/XA) | / BITNET: HIS@NIHCU INTERNET: HIS@CU.NIH.GOV \ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/