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

Hello Everyone.

I am getting little Confused while converting Numeric to Character Format.

I am having Data Like..

Data Test;

input ID Start Date9. End Date9. Amount;

Format Start End Date9.;

datalines;

1 01Jan2012 1Jan2013 5000

1 01Feb2012 1Jan2013 5000

. 01mar2012 1Jan2013 5000

0 01apr2012 1Jan2013 5000

;

run;

Data h;

set test;

x=put(ID,8.);

run;

Above Code Working Perfectly but i am getting confused with 3rd observation in above data.

Normally as per my knowledge Missing Values in Num variables shows As ' . ' and in Char values shows as Blank ' '.

But in above Data Empty value in X(3rd OBs) showing as ' . '

Why this is behaving like this???

Regards.

Sanjeev.K

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

When you have a step you want to perform just some of the time, use an IF THEN statement:

if ID > . then X = put(ID, 8.);

When ID is missing, X will remain blank.

View solution in original post

4 REPLIES 4
data_null__
Jade | Level 19

It shows dot because that is the value you PUT into it with PUT function.

Maybe you need options missing=' ';

kuridisanjeev
Quartz | Level 8

Hi.

Thanks For your reply.

If we use missing= ' ' ,then it works fine for X variable ,but other Numeric Variables also effects.But i want to keep ' . ' in other numeric variables when there is no data.

Regards,

Sanjeev.K

data_null__
Jade | Level 19

Missing option does not change the value of numeric variables.   Only the display.  So set it back when you get done.

Astounding
PROC Star

When you have a step you want to perform just some of the time, use an IF THEN statement:

if ID > . then X = put(ID, 8.);

When ID is missing, X will remain blank.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 3568 views
  • 4 likes
  • 3 in conversation