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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 2571 views
  • 4 likes
  • 3 in conversation