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 (August 2005, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 18 Aug 2005 13:04:43 +1000
Reply-To:     Scott Bass <usenet739_yahoo_com_au@ALFREDO.CC.UGA.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Scott Bass <usenet739_yahoo_com_au@ALFREDO.CC.UGA.EDU>
Subject:      Re: recoding with arrays?
Comments: To: sas-l@uga.edu

Hi Nevin,

I've seen the other responses to your post, and accept that your post is a simplification of a larger problem.

Perhaps the below will help? This assumes all variables in &new have length $3.

data test; input test $ result $ blood $; cards; Y N N Y Y N Y N N N N Y N N Y N Y Y ;

proc sql noprint; select trim(name) || "=_" || name into :rename separated by " " from dictionary.columns where libname="WORK" and memname="TEST" ; select "_" || name into :old separated by " " from dictionary.columns where libname="WORK" and memname="TEST" ; select name into :new separated by " " from dictionary.columns where libname="WORK" and memname="TEST" ; quit;

%put &rename; %put &old; %put &new;

data test2 (keep=&new); set test (rename=(&rename)); length &new $3; array old &old; array new &new; do i=1 to dim(new); if old[i] = "Y" then new[i] = "YES"; if old[i] = "N" then new[i] = "NO"; end; run;

<nevin.krishna@gmail.com> wrote in message news:1124248965.257982.310350@g43g2000cwa.googlegroups.com... > Hello All, > > i have a large number of variables which i need to recode..i am > wondering if arrays may be a time saving strategy for doing > this..please see a simple test data set below: > > data test; > input test $ result $ blood $; > cards; > Y N N > Y Y N > Y N N > N N Y > N N Y > N Y Y > ; > > i would like the ultimate recoded solution to look like this: > > YES NO NO > YES YES NO > YES NO NO > NO NO YES > NO NO YES > NO YES YES > > i realize that this would be relatively simple using formats, but i > would like to do this without using formats. > > any suggestions? > > thanks, nevin >


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