- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I am trying to compute the mean for each column when cross-tabbing the variables q46 (categorical) and q118 (nominal; 1,2,3,4,5,6,7......).
Any suggestions? Thanks!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi: What code have you tried? Are you using PROC FREQ? PROC TABULATE? PROC REPORT? PROC MEANS? Generally, it would be easier to get the mean using PROC TABULATE than PROC FREQ. And PROC TABULATE will give you percents and statistics like PROC MEANS. Since you did not post data, I made you a test program using SASHELP.SHOES so you can get the idea of how it might work.
Cynthia
ods html file='c:\temp\getmean.html' style=htmlblue;
proc tabulate data=sashelp.shoes f=comma14.2;
class product region;
var sales inventory;
table region all,
sales*(product all)*(n pctsum mean);
table region all,
inventory*product*(min max);
run;
ods html close;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Which method/procedure are you using for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi: What code have you tried? Are you using PROC FREQ? PROC TABULATE? PROC REPORT? PROC MEANS? Generally, it would be easier to get the mean using PROC TABULATE than PROC FREQ. And PROC TABULATE will give you percents and statistics like PROC MEANS. Since you did not post data, I made you a test program using SASHELP.SHOES so you can get the idea of how it might work.
Cynthia
ods html file='c:\temp\getmean.html' style=htmlblue;
proc tabulate data=sashelp.shoes f=comma14.2;
class product region;
var sales inventory;
table region all,
sales*(product all)*(n pctsum mean);
table region all,
inventory*product*(min max);
run;
ods html close;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I had been using Proc Freq, however that has given me only the %'s and n's. The code i have been using to get the %'s and n's is a simple one, just:
proc freq data=work.pwl_spss;
table q46*q118;
run;
Cynthia, will the code you posted above work given that I am only using two variables?
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
Yes, but you will have to CHANGE the code. And, because TABULATE doesn't make any assumptions, you will have to explicitly ask for the statistics you want. For example, PROC FREQ will automatically give you the N (count), Row Percent, Col Percent and overall percent, but TABULATE will only give you the count or the sum by default. So you have a bit of a TABULATE learning curve. In addition, the TABULATE table is structured differently than the FREQ table. Here are some papers on the subject to get you started:
http://www2.sas.com/proceedings/sugi30/258-30.pdf and http://www.lexjansen.com/phuse/2005/ss/ss02.pdf
and, just for fun, here's an example using PROC REPORT http://www.wuss.org/proceedings11/Papers_Miller_E_76116.pdf
cynthia