hi,
I am providing a sample of dataset that I am working with...
I want threee zeros to be added to "id" in the ouput dataset;
DATA HAVE;
INFILE DATALINES;
INPUT ID NAME : $ AMOUNT;
DATALINES;
1 ALIERN 4500
2 VEREKR 20000
3 RERRRR 100000
;
RUN;
******************************
REQUIED OUTPUT;
00001 ALIERN 4500
00002 VEREKR 20000
00003 RERRRR 100000
Regards
ALLU
Not INFORMAT reading is not the issue. You want to SEE it with leading zeros.
FORMAT AGE z5.;
You might want to consult the documentation!
data get;
format id2 $5.;
set have;
id2= '000'||strip(id);
rename id2=id;
drop id;
run;
thanks VD..
it is working...just i added another like
id2= '0000'||strip(id);
regards..
ALLU
If it's for display purposes and you want to keep the id column as numeric, then just use the Zw.d format which pads the values with leading zeros.
e.g. format id z5.;
By the way, in your required output, you've added 4 zeros not 3.
Hi keith,
I am getting error....
will you please look in to the issue...
Regards
ALLU
448 data school;
449 input Age format z5. Quiz : $1. Midterm Final;
---
48
ERROR 48-59: The informat Z was not found or could not be loaded.
450
451 id2= '000'||strip(age);
452 if age=12 then grade=6;
453 else if age=13 then grade=8;
454 datalines;
Not INFORMAT reading is not the issue. You want to SEE it with leading zeros.
FORMAT AGE z5.;
You might want to consult the documentation!
thanks...
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.