Hi Team,
I have a Zip Code 1235
0234
Need result as 12350000
02340000
Post test data in the form of a datastep. I am now having to guess if that zip code is a character or numeric variable! if its numeric then you convert it character:
data want; set have; new_zip=put(zip_code,z8.); run;
If its already character:
data want; set have; new_zip=cats(new_zip,"0000"); run;
Post test data in the form of a datastep. I am now having to guess if that zip code is a character or numeric variable! if its numeric then you convert it character:
data want; set have; new_zip=put(zip_code,z8.); run;
If its already character:
data want; set have; new_zip=cats(new_zip,"0000"); run;
Hi,
this will do the trick:
data have;
zip='1235';output;
zip='0234';output;
run;
data want;
length newzip $10;
set have;
newzip=strip(zip)||repeat('0',7-lengthn(strip(zip)));
run;
- Cheers -
data have;
zip='1235';output;
zip='0234';output;
run;
data want;
length zip $ 8;
set have;
newzip=translate(left(zip),'0',' ');
run;
@msharma1788 wrote:
Hi Team,
I have a Zip Code 1235
0234
Need result as 12350000
02340000
I have to say that is the oddest Zip code requirement unless this is a non-United States postal code. US Zipcodes are either 5 character or 5digits a dash and 4 digits: 12345-7890 example.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: