Assuming these are numbers then the following will work:
age_displayed_format shows how to change the format for display. This does not change the underlying values so you can still do calculations if necessary. Sorts will be numeric still.
age_converted shows how to change the type into a character and you cannot do mathematical calculations on the variable any longer. Sorts will be alphabetic.
I don't think in this case the sort issue matters.
data want;
set sashelp.class;
age_displayed_format = age;
format age_displayed_format z5.;
age_converted = put(age, z5.);
format age_converted $5.;
run;
proc print data=want;
var age:;
run;
@Smitha9 wrote:
Hi,
I have a data example:
ID
1
20
345
4654
I want to make the above ID to 5digits by filling the initial digits with Zero.
Example:
ID
00001
00020
00345
04654
can anyone help me with this? thank you in advance