BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
frakje
Calcite | Level 5

Hi

 

I have a char var called "cpr". My problem is when i transforms it into a numeric variable it is dropping the the start number 0 for those obs who starts with zero and returns a 9 digit num var.

 

CPR = 0101079010

 

data want;

set have;

cpr2 = input(CPR,best12.);

run;

 

returned value of cpr2 = 101079010.

 

I want that to look like the same CPR var with 10 digits but as a num var instead of a char.

 

Kind regards Frank

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Add a format in it.

 

data want;

set have;

cpr2 = input(CPR,best12.);

format cpr2 z10.;

run;

View solution in original post

2 REPLIES 2
Ksharp
Super User

Add a format in it.

 

data want;

set have;

cpr2 = input(CPR,best12.);

format cpr2 z10.;

run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 880 views
  • 0 likes
  • 2 in conversation