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

Hi,

is there any SAS numeric format, that would return these outputs from these inputs:
INPUT: 1 --- OUTPUT: 1
INPUT: 1.1 --- OUTPUT: 1,1
INPUT: 1.1235 --- OUTPUT: 1,1235

?

Basically: I need some format with decimal comma, but the only one I have found is NUMXw.d. However that gives 1,0000 out of 1. Which is what I dont want.

 

Many thanks in advance,
V.Herrmann

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

No format does this afaik. bestx shoud but doesn't.

If you really need a format, you can build it:


proc fcmp outlib=WORK.FUNCTIONS.TEMP; 
  function bestxx (NUMBER) $ ;
    return (translate(cat(NUMBER),',','.'));
  endsub;
run;

options cmplib= WORK.FUNCTIONS;    
proc format;
  value bestxx other=[bestxx()];
run;
 
data _null_;
  A= 1      ;put A= @11 A= bestxx.; 
  A= 1.1    ;put A= @11 A= bestxx.; 
  A= 1.1235 ;put A= @11 A= bestxx.; 
run;

A=1       A=1
A=1.1     A=1,1
A=1.1235  A=1,1235

View solution in original post

3 REPLIES 3
mbuchecker
Quartz | Level 8

I think you want COMMAXw.d

Michelle
ChrisNZ
Tourmaline | Level 20

No format does this afaik. bestx shoud but doesn't.

If you really need a format, you can build it:


proc fcmp outlib=WORK.FUNCTIONS.TEMP; 
  function bestxx (NUMBER) $ ;
    return (translate(cat(NUMBER),',','.'));
  endsub;
run;

options cmplib= WORK.FUNCTIONS;    
proc format;
  value bestxx other=[bestxx()];
run;
 
data _null_;
  A= 1      ;put A= @11 A= bestxx.; 
  A= 1.1    ;put A= @11 A= bestxx.; 
  A= 1.1235 ;put A= @11 A= bestxx.; 
run;

A=1       A=1
A=1.1     A=1,1
A=1.1235  A=1,1235

VojtechHerrmann
Calcite | Level 5

Thank you for your response!

V.Herrmann

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
  • 3 replies
  • 7099 views
  • 1 like
  • 3 in conversation