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 (March 2010, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 3 Mar 2010 15:36:47 -0600
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: check for variable existence, if not there put variable in.
Comments: To: Catima Potter <cpotter@kumc.edu>
In-Reply-To:  <4B8E80FC020000C7000C014A@kumc-smtpout.kumc.edu>
Content-Type: text/plain; charset=ISO-8859-1

You can always put if missing(var) then call missing(var); which is sort of cheating but works fine iff var is numeric...

Or just give the variable a format and/or length - that will initialize the variable if it's not in existence at that point.

-Joe

On Wed, Mar 3, 2010 at 3:32 PM, Catima Potter <cpotter@kumc.edu> wrote:

> Hello, > > I am writing code where I need to see if a variable exists in the > dataset. If it is not there, then I would like to include it with a > value of . (missing). I have tried this code but when the variable does > exists, it is overwriting the values to missing. Your assistance is > greatly appreciated. ~Catima > > > data have; > input _20093 _20094 rate $; > cards; > 3 1 staffing > 5 2 staffing > 7 3 staffing > 9 4 staffing > 11 5 staffing > 13 6 staffing > 15 7 staffing > 17 8 staffing > 19 9 staffing > ; > > %let pastyrqtr = _20093; > data have; > set have; > if symexist('&pastyrqtr') then put '**** &pastyrqtr exists'; > else &pastyrqtr = .; > run; >


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