| Date: | Fri, 26 Sep 2003 17:17:08 -0600 |
| Reply-To: | Michael Murff <MurffMJ@LDSCHURCH.ORG> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Michael Murff <MurffMJ@LDSCHURCH.ORG> |
| Subject: | Re: Data Step Question |
|
| Content-Type: | text/plain; charset=us-ascii |
Ben,
Try this.
data a;
set libname.a(rename=var1=var2);
keep var2 var3;
run;
You can usually pack quite a bit into one data step. Trial and error and lots of log reading is how I learned. Perhaps someone would be so kind as to generalize some SAS data step principles. In any case, you might wish to pick up a copy of "SAS Applications Programming" by Frank DiIorio; its treatment of data step functionality is pretty good.
Mike Murff
SLC, Utah
>>> "Ben Powell" <ben.powell@CLA.CO.UK> 09/25/03 07:39AM >>>
I'm not clear on what can be done in any single datastep and would
appreciate any pointers.
Say for example I want to copy a dataset to my work lib, rename a variable
and keep that and one other variable. Because in the past I have found that
sometimes a step won't action unless there is a run command after it I
would break this job into 3 seperate data steps, which is quite repetative.
Is there a rule of thumb for when a new datastep is needed and how many
steps can be included in a datastep?
e.g.
data a;
set lib.a;run;
data a (rename=(var1=var2));
set a;run;
data a;
set a;
keep var2 var3;
run;
This could be done with proc sql as
proc sql;
create table a as
select var1 as var2, var3
from lib.a;
quit;
or without the lib:
proc sql;
create table temp as
select var1 as var2, var3
from a;
create table a as
select *
from temp;
drop table temp;
quit;
Is there a tidier way to do this as a datastep?
Any help much appreciated.
------------------------------------------------------------------------------
This message may contain confidential information, and is intended only for the use of the individual(s) to whom it is addressed.
==============================================================================
|