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 (September 1997, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 1 Sep 1997 08:52:44 -0400
Reply-To:     Jules Bosch <0006974523@MCIMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Jules Bosch <0006974523@MCIMAIL.COM>
Subject:      Notes Re: Recent Posts

I finally have some time to add my input to some recent posts that have caught my interest.

First, a SAS user wanted to know how to gather info about the variables in a data set and the use of a macro was mentioned. A number of good solutions followed. One I have used on occasion comes from the SAS Guide to Macro Processing, Version 6, Second Ed., page 263. The macro provides the number of observations in a data set. There are lots of explanatory notes with the example so see the reference for more details.

It reads -

%macro numobs(dsn); %global num: data _null_; if 0 then set &dsn nobs=count; call symput('num',left(put(count,8.))); stop; run; %mend numobs;

Furthermore, the user was interested in discovering missing values in the data set. The SAS product "SAS Today - A Year of SAS Tips" (a day-at-a-time desk calendar full of interesting SAS info) lists a program that allows one to get the count and % of missing values for each var in the given data set.

It reads -

proc format; value NUMFMT . = 'missing' ._, .A-.Z = 'special missing';

value $CHARFMT ' ' = 'missing' other = 'not missing';

proc freq data=dsn; tables _all_ / missing; format _numeric_ NUMFMT. _character_ $CHARFMT.; run;

Finally, there were comments re: the lenght of a macro. The 1Q97 issue of "SAS Communications" has a technical tip that states the length of a macro is 32K. An excellent example is included to demo the development of a macro var which could easily have a length > 200 chars. The tip (p. 48) shows how to create a list (a macro var) that can be used in a WHERE statement to subset a master data set. The code from that tip follows.

data one; input empl $; cards; 12345 67890 45678 00001 98765 ... ;

data master; input empl $ job $; cards; 12345 clerk 34567 rep 00001 analyst ... ;

/* Create the macro var &LIST */ proc sql noprint; select quote (trim(left(empl))) into :list separated by " " from one; quit;

proc print data=master; where empl in(&list); run;

After resolution of the macro var the WHERE statement looks like -

WHERE EMPL IN("12345" "67890" "45678" "00001" "98765" ...);

and the values "12345" and "00001" are the only two strings found in the master data set.

The technical tips in the "SAS Communications" are often invaluable.

HTH.

Jules jules_bosch@mcimail.com


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