@sasyi wrote:
Hi,
Thank you for the suggestion. I failed to mention that the text code were just label and the values are actually coded numerically from the scale 1, 2, 3, 4, 5 and "." for missing. The example table I provided in my original post is just a simple example of what my actual dataset looks like hence why it is easy to do by hand. My actual dataset has more variables (80 variables) and observation (over 800).
I'm not really to sure what a result for this would look like on SAS, but I would imagine something similar to a Proc Freq table, where instead of being a table for just one variable (Q1), it's a combination of three variable or more (Q1, Q3, Q5).
(Q1, Q3, Q5) Frequency Percent CumulativeFrequency CumulativePercentFrequency Missing = Strongly AgreeAgreeNeutralDisagreeStrongly Disagree
Q1,Q2,Q3
Freq
Percent
Strongly Agree
Agree
Neutral
Disagree
Strongly Disagree
I hope this make sense and I apologize for any misinterpretation. Thanks again for the help.
The reason I asked about working through an example is the phrase "combination of variables". That could mean a new variable that combines the variables per respondent such as mean of the 3, or concatenated values of the three or something else.
Don't be afraid to subset and rearrange data to do analysis. I think you are looking for something like this in small:
DATA HAVE;
INPUT q1 - q4;
datalines;
1 2 3 3
1 1 4 4
2 4 2 5
;
run;
data need;
set have;
array a q1-q3;
length name $ 10;
do i=1 to dim(a);
name=vname(a[i]);
value=a[i];
output;
end;
keep name value;
label value='Vars Q1, Q2, Q2';
run;
proc freq data=need;
tables value;
run;
The array definition will subset the data to the variables of interest.
Or you could transpose of the questionnumeric variables this way. Then use Proc Freq with a Where upcase(name) in ('Q1' 'Q3' 'Q5');
To get combined frequencies of select names;
Or create format for the value of the name variable to do multiple groups at once:
data need;
set have ;
array a q1-q4;
length name $ 10;
do i=1 to dim(a);
name=vname(a[i]);
value=a[i];
output;
end;
keep name value;
run;
proc format library=work;
value $vargrp
'q1','q2' = 'Q1 Q2'
'q3','q4' = 'Q3 Q4'
;
run;
proc tabulate data=need;
class name;
class value;
format name $vargrp.;
table value,
name*(n pctn)
/misstext=' '
;
run;
... View more