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
Content-Type: text/plain; charset="iso-8859-1"
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 = '|____|||___';
INPUT P1 p2 p3;
1 2 3
4 5 1
2 3 4
5 1 2
3 4 5
5 4 3
1 2 3
3 4 5
* 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;
* Combine all variable frequencies;
SET P1freqs (IN=InP1) P2freqs (IN=InP2) P3freqs (IN=InP3);
IF (InP1) THEN
VarName = 'P1';
Value = P1;
IF (InP2) THEN
VarName = 'P2';
Value = P2;
IF (InP3) THEN
VarName = 'P3';
Value = P3;
PROC PRINT DATA=Combined;
PROC FREQ DATA=Combined;
TABLES VarName * Value;
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:-)
. . . . . . . . . . . . . . . .
Jim Groeneveld, MSc.
6825 MJ Arnhem
Tel: +31/0 26 376 7365
Fax: +31/0 26 376 7305
My statistics are quite predictable, but my computer may be quite