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 1996, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 18 Jul 1996 11:24:00 CET
Reply-To:     gio <ferro@UNI2A.UNIGE.CH>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         gio <ferro@UNI2A.UNIGE.CH>
Organization: only when absolutely necessary
Subject:      %scan and counting # of delimiters ? a macro question

I have a simple macro which I would like to improve (but can't). The purpose of the macro is to delete missing observations of relevant variables in a dataset which are needed for further use in PROC IML. The variables are stored in a macro, say; %macro myvars; educ married sex income %mend myvars; (Well, the `%let myvars=...' form could also be used, I suppose) I've written the following macro which does a nice job: %macro clean(varlist,n); %do i=1 %to &n; if %scan(&varlist,&i,%str( ))=. then delete; %end; %mend clean; The ugly part is that I have to specify myself the number of variables stored in the macro, and it can be tedious to trace it and count them. So my question is: how can I let SAS determine the number of variables in the macro which is then %scanned ? Can the number of delimiters (here single spaces) be stored somehow? Thanks for any tip. --Giovanni

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