- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I'm setting the zip code to be a 5-digit character variable, and adding a leading zero if there are only 4 digits.
data survey;
infile '/home/uid/zip.csv' delimiter=',' missover firstobs=2 dsd;
format Zip_Code $5.;
input Zip_Code $;/* I've tried all 3 but none of them worked. */
Zip_Code = put(input(Zip_Code, best12.), z5.);
Zip_Code = put(Zip_Code, z5. -L);
Zip_Code = put(Zip_Code, z5.);
And the error comes out every time
Statement is not valid or it is used out of proper order.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @aabbccwyt
I just ran the code below and it works fine...Note that I set the variable length to 5 by using the "length" statement and not by using the "format" statement. It does not explain the error you get. Perhaps you should try to narrow down where the error is originating from. Add some "put" statements to the code before each line or use the data step debugger.
data _null_;
length Zip_code $ 5;
Zip_Code = '1234';
Zip_Code = put(input(Zip_Code, best12.), z5.);
put Zip_Code=;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please post the complete log of that step.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @aabbccwyt
I just ran the code below and it works fine...Note that I set the variable length to 5 by using the "length" statement and not by using the "format" statement. It does not explain the error you get. Perhaps you should try to narrow down where the error is originating from. Add some "put" statements to the code before each line or use the data step debugger.
data _null_;
length Zip_code $ 5;
Zip_Code = '1234';
Zip_Code = put(input(Zip_Code, best12.), z5.);
put Zip_Code=;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank yall for your replies. The code
Zip_Code = put(input(Zip_Code, best12.), z5.);
is correct. I got it wrong because of a typo. I will accept @EyalGonen answer so the topic will be closed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content