First of all I need to thank everyone here whos posts I've used to help me learn more about SAS. At the moment I am building some applications to help me create tables out of a dataset. However, a problem with proc transpose arose on which I need your help.
Let's say that I've made this crossed table (results over 2 questions), where there is no-one who awnsered question 1 with a 2 AND question 2 with a 2. I get this table:
Please review your own code. The SAS PROC PRINT output you show in your post could not have been generated by the PROC TRANSPOSE code that you provided. There would not be a Q2 variable output by TRANSPOSE, unless you supply that variable in the BY statement list. You asking for assistance and guidance while not truly revealing the code and results that relate to one another.
I think that you are lacking an ID statement in your Transpose procedure. This will allow SAS to connect newly created variables to Q2 values, instead of just re-arranging values by Q1 values as it currently does.
Could you try this code and tell us if this is what you are looking for ?
(I assumed that the output table you posted add the Q1 variable as the first column, and not "Q2", as Scott pointed out.)
DATA test ;
INPUT Q1 Q2 freq ;
1 1 2
1 2 2
1 3 3
2 1 2
2 3 1
3 1 2
3 2 2
3 3 3
PROC TRANSPOSE DATA = test OUT = test2 ;
VAR freq ;
BY q1 ;
ID q2 ;