LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2001, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 13 Mar 2001 11:26:39 -0500
Reply-To:   Jim Brittain <zqr0@CDC.GOV>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Jim Brittain <zqr0@CDC.GOV>
Subject:   Report - rotated table

Hi Michele,

Sorry I am new to the SAS-L list. I tried to e-mail a response to the list but it did not get posted. I found today that you have to respond through the Internet "Compose a new message" screen. Here is what I had tried to send on 3/8/01.

When I first read your message I thought you needed to rotate an entire SAS table and make the variables observations and the observations variables. I was going to suggest Proc Transpose. After I looked at the results you were after I noticed that this looked familiar.

I did something similar to this recently. I wanted to put the results into a Proc Tabulate. Here is some code that might help. Basically you use an OUT= in your freq and then assign the counts to a variable. I used a macro and called it multiple times because each table of the freq would overwrite the previous one unless you output each table to another table. Then I appended the temp table to a master table and ran a Proc Tabulate on that. I tried this with one of your variables and it worked. You will just have to add macro calls for each of the variables that you want to add.

data test ; length gender $1 retail $1 ; input gender retail ; cards ; M C M C P C M R M R M R Z R P R P R P R P R ; run ;

proc freq data=test ; tables gender*retail / missing norow nocol nopercent ; run ;

proc datasets library=work ; delete mtemp ; quit ; run ;

%MACRO frqcount (var) ;

Proc freq data=test noprint ; tables &var*retail /list nopercent missing out=temp ; run ;

data temp ; length var $8 ; set temp (drop=percent rename=(&var=varval)) ; varname = "&var" ; run ;

proc append base=mtemp data=temp ; run ;

%MEND frqcount ;

%FRQCOUNT (gender)

proc tabulate data=mtemp format=8.0 missing ; class varname retail varval ; var count ;

table varname='VARIABLE' all ='TOTAL FOR ALL VARIABLES' ,

retail*varval='FLAG' * count=' ' * sum=' ' all ='ALL VALUES' * count=' ' * sum=' ' ; run ;

----------------------------------------------------------------------------

-----Original Message----- From: Michele Scherneck [mailto:mscherne@ROCHESTER.RR.COM] Sent: Wednesday, March 07, 2001 10:10 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Report - rotated table

Hi everyone.

I've been working with reports and I'm having trouble developing a report that looks like the following examples. In the examples, retail_ flag is categorical. Gender, State and Income contain formatted values for data checking (they're a mixture of character and numeric). I could write a PROC FREQ, like this:

proc freq formchar (1,2,7)=' '; tables _all_*retail_flag/missing nocol norow; format _character_ $pop. _numeric_ pop.; format retail_flag; run;

The output would be similar to Example 1, but what I really want is something that looks like Example 2. Any ideas about how to rotate the data into that table format?

Example 1 Retail Flag Variable | C R --------------------|-------------------------------------- Gender Missing | 2 9 Zero | 0 0 Populated | 6 3 State Missing | 4 7 Zero | 0 0 Populated | 5 2 Income Missing | 2 6 Zero | 6 3 Populated | 4 1

Example 2

Retail Flag ------------------------------------------------------------------ | C | R --------------|-------------------------|------------------------- Variable | Missing Zero Populated | Missing Zero Populated --------------|-------------------------|------------------------- Gender | 2 0 6 | 9 0 3 State | 4 0 5 | 7 0 2 Income | 2 6 4 | 6 3 1

Many thanks, michele


Back to: Top of message | Previous page | Main SAS-L page