Date: Mon, 31 Oct 2005 22:11:00 +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: SAS programming question/problem
In-Reply-To: <20051031213958.00BE01F50B1@ws1-2.us4.outblaze.com>
Content-Type: text/plain; format=flowed
Nick,
Use proc import to get your data into SAS from excel.
Then :
/******************************/
/** Create Some Data To Rename***/
/*****************************/
data one ;
var1 = 'VAR1' ;
var2 = 'VAR2' ;
var3 = 'VAR3' ;
var4 = 'VAR4' ;
var5 = 'VAR5' ;
run ;
/***************************/
/** You would use proc import **/
/** or something to get your **/
/** data into SAS here. **/
/***************************/
data two ;
infile cards ;
input oldname $ newname $ ;
cards ;
var1 newvar1
var2 newvar2
var3 newvar3
var4 newvar4
var5 newvar5
;
run ;
filename names temp ;
data _null_ ;
file names ;
set two ;
put 'rename ' oldname '=' newname ';' ;
run ;
proc datasets lib = work ;
modify one ;
%include names ;
run ;
quit ;
Toby Dunn
From: "Nick ." <ni14@MAIL.COM>
Reply-To: "Nick ." <ni14@MAIL.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: SAS programming question/problem
Date: Mon, 31 Oct 2005 16:39:58 -0500
Hello,
I have a SAS (V8.2) data set with, say, 5 fields (in my data set it has like
500 fields) called VAR1, VAR2,..., VAR5.
I have an Excel data set that looks like this:
A B
VAR1 Age
VAR2 Income
VAR3 Gender
VAR4 Num_Accts
VAR5 Zip_Code
I need to go to my SAS data set above and replace the field names
VAR1,...,VAR5 with Age, Income, Gender, Num_Accts, Zip_Code respectively. (A
and B are the column headings in Excel sheet, not of importance, I guess.)
Someone asked me why I need this. I need this for modeling. People need to
know what VAR1, VAR2, VAR3, etc. mean.
NOTE: The crux of my question is how to AUTOMATE the above. If I had to go
and use RENAME or do this in a data step using INPUT, I know that stuff,
yes, I can do it. But it is a lot of typying (and lot's of wrrors)...500
inputs and long names. Very long names, lot's of typing. What if instead of
500 inputs I had 5,000 inputs? Say 50,000 inputs VAR1...VAR50000. Will I
still sit there typying for 3 months? I was looking for an automated way to
accomplish this task. Thanks as always.
NICK
--
___________________________________________________
Play 100s of games for FREE! http://games.mail.com/