Help using Base SAS procedures

leading zero issue

Reply
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,257

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: 10,516

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.

Contributor
Posts: 70

Re: leading zero issue

Hi..

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

data test;

input ID first $ last $;

format id Z6.;

cards;

056746 Sr M

;

run;

proc print;

run;

Ask a Question
Discussion stats
  • 4 replies
  • 263 views
  • 0 likes
  • 5 in conversation