BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
djbateman
Lapis Lazuli | Level 10

I have several macro variables that represent a numeric value.  I understand that macro variables are character strings, so I can't format them as I could a number.  I want the variables to display to 1 decimal point, but there are some that only an integer.  For example, I want the value "1" to display as "1.0".  I am trying to add the string ".0" to any variable that represents an integer.  The code below does not work.  It likes to remove the decimal and display "10" instead of "1.0".  Any ideas on how to retain the decimal point?

%let zerodec=%quote(.0);

%put ~~~&zerodec.~~~;

%let dose1=1;

%let dose1=%sysfunc(cat(&dose1.,%quote(&zerodec.)));

%put ~~~&dose1.~~~;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

dose1 = %sysfunc(putn(&dose1,f3.1));

A macro value that will resolve to a number can be "formatted" using PUTN (not just PUT)

View solution in original post

2 REPLIES 2
ballardw
Super User

dose1 = %sysfunc(putn(&dose1,f3.1));

A macro value that will resolve to a number can be "formatted" using PUTN (not just PUT)

Patrick
Opal | Level 21

What about?

%let str=1;

%let str=%sysfunc(inputn(&str,best32.),16.1);

%put str: &str;

Result:

str: 1.0

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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