Date: Mon, 28 Nov 2011 10:46:14 -0600
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: producing frequency percentages for multiple questions
Content-Type: text/plain; charset=windows-1252
Q1 is a stat (first quartile), so you'd have to rename Q1 to be a
different name to use it in PROC TABULATE. You can do so in the proc:
ods output table=table_data;
proc tabulate data=have(rename=q1=q_1 q2=q_2 q3=q_3);
class q_1 q_2 q_3 q4 q5 ... product; *only need to rename 1 through 3,
and even really don't need to rename 2;
tables (q_1 q_2 q_3 q4 q5 ...),(all product);
ods output close;
Something like that should get you what you want, though some
manipulation will be required, and if you have potential missing
values for some of the questions you may not get quite what you want.
A slightly better solution is to preprocess the data. Convert the
data to a vertical structure, with PRODUCT, Q_NAME, and VALUE (and
perhaps a respondent ID or something else), where Q_NAME has "q1" "q2"
... in it.
array qs q1-q14;
do _t = 1 to dim(qs);
q_name = vname(qs[_t]);
value = qs[_t];
keep product q_name value;
ods output table=want;
class product q_name value;
tables q_name*value,(all product);
ods output close;
Something like that would probably give you a more easily manageable
dataset. If this doesn't do precisely what you want then provide some
sample data and an example of your desired output and we can probably
help you further.
On Sat, Nov 26, 2011 at 2:06 PM, Painter, John (jsp9a)
> Dear List,
> I need to summarize % endorsing each response option for customer satisfaction survey data consisting of 14 questions (4-pt likert type scale) and 30 products. The data are summarized overall for each of the 14 questions, then by product so I have 31 tables in the end.
> It has been a while since I’ve attempted this in SAS. For the overall table I can obtain the frequency stats using proc freq, save each data file, and concatenate them to form the desired table. But this seems very clumsy. Is there a more efficient procedure?
> For the second type of report table I started with proc tabulate and this code:
> Proc tabulate ;
> Class product q1 ;
> Table product q1 ;
> Run ;
> ODS OOUTPUT table=q1 ;
> Which delivers the error “The variable Q1 conflicts with the keyword of the same name.” The output looks like something I can use in a data step, but of course no data file is produced. Any advice? I would prefer to have percentages instead of counts. And I would like to include all 14 items in one analysis, instead of running the same procedure 14 times.
> Hopefully this makes sense.
> Thank you,