BookmarkSubscribeRSS Feed
Bassi
Calcite | Level 5

Hi!

I have one question.

I have a numers in commax30. format which are saved in macro variable. (e.g.  first numer= 35.258.698, second numer=58.258.369 an so one.., every numer contains 2 dots)

When i try to summarize this two or more numer i get an error bescause numbers has 2 dots.

I tried with more combinations and i do not know how to resolve this problem.

The numbers must be in defined formats commax30. and i do not want define duplicate macro variable just for summarizing.

Does anyone have any idea.

For example:

%let var1=25.598.659;

%let var2=32.589.124;

%let sum=%syseval(&var1+&var2);

%put ∑

Thx for help.

Mladen

7 REPLIES 7
Hima
Obsidian | Level 7

Please help me understand why would a number have 2 dots. Can this 25.598.659 be assumed as 25,598,659?

Bassi
Calcite | Level 5

Hi!

Because my client wants result in this format. 25,598,659 is not acceptable format for my reports.

I can define duplicate macro variable but this is too complicated.

So, i try to fine more elegant solution.

Thx for questions.

Reeza
Super User

Is it basically the european format for a number, decimal instead of comma?

I think Hima's question needs to be answered, otherwise how do the numbers add together, ie Do all numbers have 2 periods and do all have 8 digits? 

Assuming you can't just use the commax format in your final report and store intermediaries in the north american standard notation my suggestion would be to convert to comma notation and the reconvert back to commax format. 

%let var1=25.598.659;

%let var2=32.589.124;

%let cvar1=%sysfunc(inputn(&var1, commax30.));

%let cvar2=%sysfunc(inputn(&var2, commax30.));

%put &var1 &var2 &cvar1 &cvar2;

%let sum=%sysfunc(putn(%sysevalf(&cvar1 +&cvar1), commax30.));

ballardw
Super User

Since you are creating the macro variables as text somewhere DON'T use a format until final output.

Bassi
Calcite | Level 5

Hi!

Thanks everyone for help and suggestions.


I will try some of this solutions.

Thx, one more time.

Mladen

tihoz
Calcite | Level 5

Hi,

what about when we have commaxw.d, when d>0

for example

%let var1=25.598.659,6;

%let var2=32.589.124,9;

Thanks in advanced.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2447 views
  • 0 likes
  • 6 in conversation