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 (December 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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?
In-Reply-To:  <40918322-ab63-431f-8ce4-a30582090366@u25g2000prh.googlegroups.com>
Content-Type: text/plain; charset=us-ascii

see the Nitems macro:

http://www.sascommunity.org/mwiki/images/7/77/Nitems.sas

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? > > Hi, > > 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; > end; > run; > > Any help is appreciated!!! > > Thanks. > > Taka > > how can I automatically count the number of itesm in this macro > variable? > >


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