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 (December 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 4 Dec 2008 09:24:56 -0600
Reply-To:     Mary <mlhoward@avalon.net>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Mary <mlhoward@AVALON.NET>
Subject:      Re: format help asap
Comments: To: Fatos Simsek <fatosus@GMAIL.COM>
Content-Type: text/plain; format=flowed; charset="Windows-1252";
              reply-type=original

The problem is that Proc Freq does thing alphabetically, so that your nonrespondent is alphabetically less than your respondent.

A bit longer approach, if you really wanted to control how it looks, would be to save the output to proc freq and then sort it and use proc report instead. Here's an example:

proc format; value $resp 'R'='respondent' 'NR'='nonrespondent'; value $incent 'CD'='CD' 'F'='Magnet '; ;

data test; informat response incentive $2.; infile cards; input response 1-2 incentive 3-4; format response $resp. incentive $incent.; cards; R CD R CD R CD R F NRCD ;

ods trace on; ods output CrossTabFreqs=CrossTabFreqs_set; proc freq data=test; tables response*incentive; run;

data CrossTabFreqs_set; set CrossTabFreqs_set; if _type_='11'; drop table _type_ _table_; run;

proc sort data=CrossTabFreqs_set; by descending response; run;

proc contents varnum data=CrossTabFreqs_set; run;

proc report data=CrossTabFreqs_set nowindows style(report)=[rules=all cellspacing=0 bordercolor=lightgreen] style(header)=[background=lightskyblue foreground=black] style(column)=[background=white foreground=black vjust=top];

column response incentive Frequency Percent RowPercent ColPercent Missing; define response/display 'Response'; define incentive/display 'Incentive'; define Frequency/display 'Frequency'; define Percent/display 'Percent'; define RowPercent/display 'Row Percent'; define ColPercent/display 'Column Percent'; define Missing/display 'Missing'; run;

-Mary ----- Original Message ----- From: Fatos Simsek To: SAS-L@LISTSERV.UGA.EDU Sent: Thursday, December 04, 2008 8:53 AM Subject: format help asap

Hi All, I need format help, please. Here is the formats I defined:

*proc* *format*;

value $resp 'R'='respondent' 'NR'='nonrespondent'; value $incent 'CD'='CD' 'F'='Magnet ';* * ** * * I get a freq table below:

Table of resp by incent

resp incent

Frequency ‚

Percent ‚

Row Pct ‚

Col Pct ‚CD ‚Magnet ‚ Total

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

nonrespondent ‚ 206 ‚ 215 ‚ 421

‚ 32.91 ‚ 34.35 ‚ 67.25

‚ 48.93 ‚ 51.07 ‚

‚ 65.61 ‚ 68.91 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

respondent ‚ 108 ‚ 97 ‚ 205

‚ 17.25 ‚ 15.50 ‚ 32.75

‚ 52.68 ‚ 47.32 ‚

‚ 34.39 ‚ 31.09 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

Total 314 312 626

50.16 49.84 100.00

I would like to see the respondent in the first line rather than the second line. How can I fix it? thanks a lot. Fatosh


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