BookmarkSubscribeRSS Feed
Shrij
Calcite | Level 5
I have three columns were the data should be in 2 or three figures but the should not start with a 0, but i have a few values where the figure is of 2 digits but with a zero for example :

DIBP

82
86
85
084
85
86
083


How do i remove the zero's
4 REPLIES 4
gamotte
Rhodochrosite | Level 12

Are those columns of a SAS dataset ?

If so, does this mean that values are stored as character variables ?

Why not use a numeric format since your data is of numeric nature ?

 

Tom
Super User Tom
Super User

Use SUBSTR() function.  Either start from the 1st or the 2nd character depending on whether it starts with zero or not.

DIBP=substr(DIBP,1+DIBP=:'0');
Ksharp
Super User
data have;
input DIBP $;
want=prxchange('s/^0+//',1,dibp);
cards;
82
86
85
084
85
86
083
;
run;
Reeza
Super User
I'm with @gamotte, the type of your data is more important. Numeric variables do not have a leading 0 by default, so I'm guessing it's character. If that's the case and you want to do any math with these values you'll also need a type conversion and if you're doing that you can avoid dealing with the leading 0 at all.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1323 views
  • 0 likes
  • 5 in conversation