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 (June 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sat, 17 Jun 2006 13:03:20 -0700
Reply-To:   pchoate <paulchoate61@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   pchoate <paulchoate61@GMAIL.COM>
Organization:   http://groups.google.com
Subject:   Re: problem with an IF statement in data step and wildcard
Comments:   To: sas-l@uga.edu
In-Reply-To:   <200606171755.k5HHVTPL026941@mailgw.cc.uga.edu>
Content-Type:   text/plain; charset="iso-8859-1"

J -

The colon operator is a good idea, but usually to work across a set of variables you need an array. You can, if you want, use the colon operator to define an array.

Here's the old implicit array form with the colon operator used to reset vars named D* to missing:

data test; set sashelp.column; array dvars d:; do over dvars; dvars=.; end; run;

As long as the D* variables are all numeric this will work. :-)

With subscripted arrays you have a bit more control, but you have worry about the subscript:

data test(drop= _:); set sashelp.column; array dvars d:;

do _i= 1 to hbound(dvars); dvars(_i)=.; end; run;

If your variables are a mix of alpha and numeric then they have to be in different arrays.

hth

Paul Choate

j Doyle wrote: > I have a data set that looks like this > year Parm B_all_rank t_all_rank R2_all_rank N_all_rank > 1991 wrca -0.011541479 -1.43 0.220561 1069 > 1991 wrpa 0.158115362 2.96 0.220561 1069 > 1992 wrca -0.0052803 -0.33 0.236125 1074 > 1992 wrpa 0.509624581 3.48 0.236125 1074 > 1993 wrca -0.024893701 -0.67 0.156986 1087 > 1993 wrpa 0.463114183 3.65 0.156986 1087 > > except that I have many more columns with variable names: B_newname, > t_newname, R2_newname, and N_newname, etc. > > My goal is to clean up this table so that the R2 and the N values by year > are not repeated as they are above, so I am trying to remove them (they > were copied down in a merge), so I tried this > > if year = lag(year) then R2: = .; > if year = lag(year) then N: = .; > > Although it didn't work, it did work when I used the actual variable name > R2_all_rank, etc. I would like to be able to use wildcards, but am not > very experienced with them. Is an array the way to go? > Thank you in advance > j doyle


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