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 (July 2004, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 9 Jul 2004 10:28:59 +0200
Reply-To:     "Groeneveld, Jim" <jim.groeneveld@VITATRON.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Groeneveld, Jim" <jim.groeneveld@VITATRON.COM>
Subject:      Re: output question
Comments: To: Adriano Rodrigues <adriano@GPP.COM.BR>
Content-Type: text/plain; charset="iso-8859-1"

Hi Adriano,

The following code does what you requested. It possibly could even be programmed more optimal and efficient; I will think about that. This may serve as the basis for a general macro MultFreq (for variable list frequencies) to write sometime (also supporting character variables and missing values) (if Roland Rashleigh-Berry or someone else doesn't have or develop it already, and if time permits me to do so). You may adapt the final PROC FREQ step to meet your display needs. Instead you could use PROC TABULATE or REPORT. In my macro I would go for PROC REPORT to force an even nicer looking display.

OPTIONS ls=80 ps=63 formchar = '|____|||___';

DATA TestData; INPUT P1 p2 p3; CARDS; 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 5 4 3 1 2 3 3 4 5 ; RUN;

* Save frequencies of each variable in datasets; PROC FREQ DATA=TestData; TABLES P1 / NOPRINT OUT=P1freqs; TABLES P2 / NOPRINT OUT=P2freqs; TABLES P3 / NOPRINT OUT=P3freqs; RUN;

* Combine all variable frequencies; DATA Combined; SET P1freqs (IN=InP1) P2freqs (IN=InP2) P3freqs (IN=InP3); IF (InP1) THEN DO; VarName = 'P1'; Value = P1; END; IF (InP2) THEN DO; VarName = 'P2'; Value = P2; END; IF (InP3) THEN DO; VarName = 'P3'; Value = P3; END; RUN;

PROC PRINT DATA=Combined;

PROC FREQ DATA=Combined; TABLES VarName * Value; WEIGHT Count; RUN;

Thank you for forcing me to think of such a nice tabulation, which I will use myself as well, for the time being as dedicated (non-general) code.

Regards - Jim.

Adriano Rodrigues wrote: > Hi Jim, > > > Yes, are freqs. > > I want one code like: > proc freq; > table p1 p2 p3 / alltogetherinonetableinrows; run; > > but the results in the format > > 5 4 3 2 1 0 > p1 30.0 20.0 10.0 0.0 10.0 30.0 > p2 40.0 60.0 0.0 0.0 0.0 0.0 > p3 50.0 10.0 0.0 40.0 0.0 0.0 > > with out comand i can make this, but is not fast method...(i think) > :-) > > Thx anyway:-) > > Adriano

-- . . . . . . . . . . . . . . . .

Jim Groeneveld, MSc. Biostatistician Science Team Vitatron B.V. Meander 1051 6825 MJ Arnhem Tel: +31/0 26 376 7365 Fax: +31/0 26 376 7305 Jim.Groeneveld@Vitatron.com www.vitatron.com

My statistics are quite predictable, but my computer may be quite unpredictable.

[common disclaimer]


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