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.

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
  • 7 replies
  • 1050 views
  • 0 likes
  • 6 in conversation