12-02-2014 11:46 PM
is there a way to separate the sub levels of a variable so that the sub levels are in rows and the variables are as columns. To illustrate what i mean, attached is a picture. First picture is in sas, second picture is what i would like to do in sas. Apologies if this is covered else where, but i have literally searched everywhere without success. I am guessing it is called something else since these seems like a pretty simple/common approach to creating a table. Below is the code. Any guidance would be greatly appreciated! thanks!
proc tabulate data=scores;
class Q1 Q2;
12-02-2014 11:59 PM
First picture can't be your data in SAS, that's the report. You need to show what your actual data looks like.
Unless you have them backwards?
The word you're looking for is transpose though:
12-03-2014 10:23 AM
Yup exactly, I need the raw data (pic 3) summed like it is in pic 1 and pic 2. the first picture shows the counts for the subcategories within a variable (categorical) from sas, pic 2 is the format i would like it in. So for example, the possible choices for Q1 are 1 - 5. 8 people responded 1, 7 people ressponded 2 etc. So It shows the counts for each choice. The third picture is just the raw data. For now what i do is get counts, export it to excel and create pivot tables to achieve this. But Im wondering if htere is a quicker way to do this.
12-03-2014 02:35 PM
Yes, but the data you showed only shows a portion of your problem. It would help if you would illustrate the full problem with sample data in the text here so we can use it directly rather than type it out. The general solution will be along the lines of query, with a specific group by clause and then sum or count the values as required. That will create the data set and then you can easily print out that data set using the LIST task
12-03-2014 05:10 PM
You are wanting two univariate summaries.
One way is to put all the results into a single variable:
data allscores; * or use proc transpose;
q='q1'; result=q1; output;
q='q2'; result=q2; output;
proc tabulate data=allscores;
class q result;
table result,q ;