Date: Thu, 10 Dec 2009 15:28:16 -0500
Reply-To: "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV>
Subject: Re: how to count the number of elements in a macro variable?
Content-Type: text/plain; charset=us-ascii
see the Nitems macro:
summary use functions compress and countc
Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov
> From: Takatsugu
> Sent: Thursday, December 10, 2009 2:32 PM
> Subject: how to count the number of elements in a macro variable?
> I am a newbie to SAS and use SAS at work while I have experience in
> using R for a while.
> I would like to know how to automatically determine the length of
> &vars (=5) instead of declaring 10 in the below script....
> %let vars = A B C D E;
> data _NULL_;
> do i = 1 to 10; <---- this value of 10 is what I would like to
> automate when I change &vars.
> letter = scan(&vars., i, ' ');
> put i letter;
> if letter = " " then leave;
> Any help is appreciated!!!
> how can I automatically count the number of itesm in this macro