| Date: | Fri, 23 Jul 2004 10:22:09 -0400 |
| Reply-To: | "Braten, Michael (Exchange)" <mbraten@BEAR.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Braten, Michael (Exchange)" <mbraten@BEAR.COM> |
| Subject: | Re: add in a value |
|
| Content-Type: | text/plain; charset="us-ascii" |
The input statement is used to read data into a datastep when it is in
an external file. You are adding a variable to the data once it has been
read in. The length statement will create the new variable. The
Retain will
initialize it to a value of 04 and keep that value . You then write it
at the end of the record.
DATA _NULL_;
INFILE MFR;
INPUT @ 1 DATA $140.;
Length yr $ 2;
Retain yr '04';
FILE OUT ;
PUT @001 DATA $140.
@141 yr $char2. ;
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Mai
To
Sent: Friday, July 23, 2004 10:10 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: add in a value
I have a dataset with many fields. I need to add in a field "YR" with a
value "04" at the end of each record to identify the year. This is my
code:
DATA _NULL_;
INFILE MFR;
INPUT @ 1 DATA $140.
@ 145 YR $2.
;
IF YR=' ' THEN YR='04';
FILE OUT ;
PUT _INFILE_;
But it doesn't work. Any help is very much appreciated.
Mia
***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation,
offer or agreement or any information about any transaction, customer
account or account activity contained in this communication.
***********************************************************************
|