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 (November 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 22 Nov 2006 10:34:28 -0500
Reply-To:   Jack Clark <JClark@CHPDM.UMBC.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Jack Clark <JClark@CHPDM.UMBC.EDU>
Subject:   Re: PROC FREQ
Comments:   To: "priyaworld2@YAHOO.COM" <priyaworld2@YAHOO.COM>
Content-Type:   text/plain

This is one approach using the SASHELP.VCOLUMN table.

* create sample data ; data dat1; input disp3_1 $ disp3_2 $ disp3_4 $; cards; A B C D E F G H I ; run;

* create sample data ; data dat2; input disp3_1 $ disp3_3 $ disp3_5 $; cards; J K L M N O P Q R ; run;

* provide the dataset name as a macro parameter ; %macro getdisp (dsname);

proc sql noprint; select name into :vnames separated by ' ' from sashelp.vcolumn where libname = "WORK" and memname = upcase("&dsname") ; quit;

%put &vnames;

title1 "Frequencies for &dsname Dataset"; proc freq data = &dsname; tables &vnames; run;

%mend getdisp;

%getdisp (dat1); %getdisp (dat2);

Jack Clark Research Analyst Center for Health Program Development and Management University of Maryland, Baltimore County

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of priyaworld2@YAHOO.COM Sent: Wednesday, November 22, 2006 9:08 AM To: SAS-L@LISTSERV.UGA.EDU Subject: PROC FREQ

Hi All,

While writing a PROC FREQ statement, in the TABLES statement can we specify variables like starting with something option. For eg, in a dataset I have variables like DISP3_1 DISP3_2 DISP3_4 DISP3_6. Because of the discontinuity in the numbering, the below code using do loop gives me an error:

do i = 1 to 6; proc freq data = dat1; tables DISP&i; run;

ERROR: DISP3_3 NOT FOUND. DISP3_5 NOT FOUND.

This procedure has to be run for different datasets where we have different DISP variables.So, there is not a fixed pattern for these varibles.( dat2 may have DISP4_1 DISP4_2 DISP4_3 DISP4_5 etc...)

Can we write a code where we can specify the option to get all variables starting with "DISP"?

Kindly suggest a way.


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