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

Hi ,

I have data with variable x which has values

$105.00
$120.00
$135.00
$15.00

$1.39

 

how to convert to  numeric number format with decimal places

 105.00
120.00
135.00
15.00

 

can anyone pls help

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

If you want to change the format, apply a new format. 

 

INPUT/PUT are for type conversions -> character to numeric or numeric to character.

 

format variable 8.2;

Here's a fully worked example.

 

data have;
retain actual sample1 sample3 predict sample2;
set sashelp.prdsal2(obs=20);
sample1=actual;
sample2=predict;
sample3=floor(actual); *Round down to 0 decimal places;

format sample1 8.2;
format sample2 8.;
format sample3 8.2;

keep actual sample1 sample3 predict sample2;
run;

proc print data=have;
run;

 

 

View solution in original post

2 REPLIES 2
chennupriya
Quartz | Level 8

Currently to achieve I am using below code

 

(input(put(X,10.4),10.2)) AS XY

 

but I am getting

105
120
135
15

1.39

but i am not getting zeros

Reeza
Super User

If you want to change the format, apply a new format. 

 

INPUT/PUT are for type conversions -> character to numeric or numeric to character.

 

format variable 8.2;

Here's a fully worked example.

 

data have;
retain actual sample1 sample3 predict sample2;
set sashelp.prdsal2(obs=20);
sample1=actual;
sample2=predict;
sample3=floor(actual); *Round down to 0 decimal places;

format sample1 8.2;
format sample2 8.;
format sample3 8.2;

keep actual sample1 sample3 predict sample2;
run;

proc print data=have;
run;

 

 

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
  • 2 replies
  • 19173 views
  • 0 likes
  • 2 in conversation