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

Hello Experts,

 

I have a numeric value with comma 

-0,165530135449

I would like to have this value with a point: -0.165530135449

Could you advise me the format please, the best32. doesn't work.

 

 

Thank you very much!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

Try this:

 

data _null_;
  x = -0.165530135449;

  put x= bestx32.15;
  put x= best32.15;
  put x= comma32.15;
  put x= commax32.15;
run;


data _null_;
input x commax32.;


  put x= bestx32.15;
  put x= best32.15;
  put x= comma32.15;
  put x= commax32.15;


cards;
-0,165530135449
;
run;
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

9 REPLIES 9
yabwon
Onyx | Level 15

Try this:

 

data _null_;
  x = -0.165530135449;

  put x= bestx32.15;
  put x= best32.15;
  put x= comma32.15;
  put x= commax32.15;
run;


data _null_;
input x commax32.;


  put x= bestx32.15;
  put x= best32.15;
  put x= comma32.15;
  put x= commax32.15;


cards;
-0,165530135449
;
run;
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SASdevAnneMarie
Barite | Level 11
Thank you very much!
Could I do that with modify statement in proc sql? I need to modify the existing format column in the table.
yabwon
Onyx | Level 15
data have;
  x = -0.165530135449;
  format x datetime.; /* wrong format */ 
run;
proc print data = have;
run;

proc sql;
  alter table have
    modify x format=commax32.15 /* new format */
  ;
quit;
proc print data = have;
run;

B-)

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SASdevAnneMarie
Barite | Level 11
It replaces the comma by point?
yabwon
Onyx | Level 15

what do you mean by "it"?

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SASdevAnneMarie
Barite | Level 11
The format commax32.15 🙂
PaigeMiller
Diamond | Level 26

@SASdevAnneMarie wrote:
It replaces the comma by point?

Formats change the appearance of the number for the benefit of humans looking at the number; the underlying numeric value is unchanged. I don't think the word "replaces" applies here.

--
Paige Miller
SASdevAnneMarie
Barite | Level 11
Yes, it works, beacause after I can export the file with period.
Tom
Super User Tom
Super User

@SASdevAnneMarie wrote:

Hello Experts,

 

I have a numeric value with comma 

-0,165530135449

I would like to have this value with a point: -0.165530135449

Could you advise me the format please, the best32. doesn't work.

 

Thank you very much!


If you have a numeric variable and it is display the decimal marker as a comma instead of a period then you have either attached a format that asks to display that way (BESTX, COMMAX, NLNUM) or the SAS session is running with language settings that tells SAS you are in a part of the world where comma is the normal character to use.

 

Check what format is attached to the variable. For example by running PROC CONTENTS on the dataset.

 

You can use the NLNUMI format to force SAS to display the values with period for the decimal place and comma as the thousands separators no matter what the language settings are..  

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 9 replies
  • 1905 views
  • 2 likes
  • 4 in conversation