DATA Step, Macro, Functions and more

how can i get '0' as prefix.

Reply
New User
Posts: 1

how can i get '0' as prefix.

how can i get prefix zero for the following?

1

23

123

22.1

is it possible for me get in following manner?

001

023

123

22.1 or ?

SAS Super FREQ
Posts: 685

Re: how can i get '0' as prefix.

Hi

 

The Zw. format will give leading zeros, see sample code below. Whether you use just a format or convert the number to a char value depends on what you want to use it for.

data have;
  infile cards;
  input
    value
  ;

  value_c = put(value, z3.);
  format value z3.;
cards;
1
23
123
22.1
;

proc print data=have;
run;

Bruno

Super User
Posts: 10,550

Re: how can i get '0' as prefix.

Is your variable numeric or character?

If numeric a format of Z5.1 might work but with an assigned decimal part ALL variables would show a decimal.

Ask a Question
Discussion stats
  • 2 replies
  • 158 views
  • 0 likes
  • 3 in conversation