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 (April 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 16 Apr 2008 04:16:28 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: Array data checks (non sequential)
Comments: To: nevin <nevin.krishna@gmail.com>
In-Reply-To:  <1f998ade-b235-4c10-a0db-b9921ea391ba@a1g2000hsb.googlegroups.com>
Content-Type: text/plain; charset="Windows-1252"

Data _Null_ ; File Print ; Set Two ; Array MyVars ( * ) Surv Var1 Var2 Var3 ;

Do I = 1 To Dim( MyVars ) ; If PRXMatch( '/[a-z]/io' , MyVars( I ) ) Then Do ; VarName = Strip( VName( MyVars( I ) ) ) ; BadChars = Quote( Strip( Compress( MyVars( I ) , , 'KA' ) ) ) ; Put 'Record: ' ID +(-1) ' Contains A ' BadChars +(-1) ' In Variable ' VarName ; End ; End ;

Run ;

Toby Dunn

"Don't bail. The best gold is at the bottom of barrels of crap." Randy Pausch

"Be prepared. Luck is where preparation meets opportunity." Randy Pausch

> Date: Tue, 15 Apr 2008 19:13:00 -0700 > From: nevin.krishna@GMAIL.COM > Subject: Array data checks (non sequential) > To: SAS-L@LISTSERV.UGA.EDU > > Hello All, > > i am trying to create custom error messages identifying observations > which have inappropriate data. In this case, characters are considered > inappropriate. for the error message i wish to state the observation > value and the variable name which contains the character. The first > example contains the three variables which are all continuous > (var1,var2,var3) and the error message works fine (due to the fact > that i can take advantage of i ). > > The second example is really the point of my question. In it there are > four variables; surv var1 var2 var3. The problem i am having here is > figuring out how to get the variable 'surv" to display in the error > message instead of "var1". I thought of using formats and cntlin, > but i dont think it will work since there may be more than one "error" > per obs (so the format dataset will have two or more format "labels" > per id). Any ideas on how to get the variable name "surv" to show up? > > thanks! > > -nevin > > ***Example1**** > data one; > input id var1 $ var2 $ var3 $; > cards; > 1 1272 A232 399b > 2 A163 3939 P343 > ; > run; > data _null_; > set one; > file print; > array strchk (*) var1-var3; > do i=1 to dim(strchk); > if substr(strchk(i),1,1)='A' then do; > put 'record ' id ' contains an "A" in > variable var' i; > > end; > else if substr(strchk(i),1,1)='P' then do; > put 'record ' id ' contains an "P" in > variable var' i; > end; > end; > run; > > > *********Example2********** > > data two; > input id surv $ var1 $ var2 $ var3 $; > cards; > 1 P172 1272 A232 399b > 2 2727 A163 3939 P343 > ; > run; > data _null_; > set two; > file print; > > array strchk (*) surv var1 var2 var3; > do i=1 to dim(strchk); > if substr(strchk(i),1,1)='A' then do; > put 'record ' id ' contains an "A" in > variable var' i; > > end; > else if substr(strchk(i),1,1)='P' then do; > put 'record ' id ' contains an "P" in > variable var' i; > end; > end; > run;

_________________________________________________________________ Pack up or back up–use SkyDrive to transfer files or keep extra copies. Learn how. http://www.windowslive.com/skydrive/overview.html?ocid=TXT_TAGLM_WL_Refresh_skydrive_packup_042008


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