Help using Base SAS procedures

leading zero issue

Senior User
Posts: 1

leading zero issue

Hi ,

I have a text file with the following 3 values separated by spaces :

056746    Sr    M    

When I read this file in SAS and print the output, the leading 0 is missing. Eg: 056746 is displayed as 56746.

Can you please help me with command and syntax that will help me display the entire value(with leading zeros)

I tried various possibilities with FORMAT, but with no success. Please help asap.

Thanks for your time

Super User
Posts: 5,881

Re: leading zero issue

Use the z. format, or import the column as char.

Data never sleeps
Super Contributor
Posts: 1,636

Re: leading zero issue

did you try

format your_variable z6.; ?

Super User
Posts: 13,542

Re: leading zero issue

Are you doing arithmetic with the first variable such as sum, mean, standard deviations? If not make it character and avoid lots of issues.

Posts: 70

Re: leading zero issue


Use format Z. is the best way to keep leading Zeros..

data test;

input ID first $ last $;

format id Z6.;


056746 Sr M



proc print;


Ask a Question
Discussion stats
  • 4 replies
  • 5 in conversation