Barite | Level 11

## Decimal in macro variable

Hello Experts,

I'm wondering how to get the decimal after the sum statement, the decimal doesn't appear in my macro variable Montant_EU. My code is  :

``````proc sql noprint;
select sum("Montant EU "n)
into : Montant_EU
from base_finale;
quit;
``````

Thank you for your help !

11 REPLIES 11
SAS Super FREQ

## Re: Decimal in macro variable

I think you don't have any decimals (the sum is an integer).

Anyway,

if you absolutely want decimals

, here's one way to get them.

``````proc sql noprint;
select put(avg(Weight),comma14.7)
into :Montant_EU trimmed
from sashelp.class;
quit;

%PUT &=Montant_EU;``````

Koen

Barite | Level 11

## Re: Decimal in macro variable

Thank you! Why %eval function doesn't work for this macro variable :
%let tx=%eval(&Montant_EU+1) ?

Diamond | Level 26

## Re: Decimal in macro variable

@SASdevAnneMarie wrote:
Thank you! Why %eval function doesn't work for this macro variable :
%let tx=%eval(&Montant_EU+1) ?

--
Paige Miller
SAS Super FREQ

## Re: Decimal in macro variable

You could use "sysevalf" :

``````proc sql noprint;
select put(avg(Weight),comma14.7)
into :Montant_EU trimmed
from sashelp.class;
quit;

%PUT &=Montant_EU;

%LET tx=%sysevalf(&Montant_EU.+1);
%PUT &=tx;``````

Koen

Barite | Level 11

## Re: Decimal in macro variable

This code doesn't work on my EG, I have this erros :

SAS Super FREQ

## Re: Decimal in macro variable

Can you copy / paste the full code (as part of the full log)?

• Copy in EGuide
• Then use the </> icon in the header
• Then paste in the pop-up window.
• (Avoid screenshots here)

Thanks,
Koen

Super User

## Re: Decimal in macro variable

That looks like  an un-related problem.  It looks like at some point in the SAS session, you may have submitted a block of code with unmatched quotation marks.  If you get this problem repeatedly, the easiest thing is to exit EG and then restart, and then search your code for unmatched quotation marks.

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Super User

## Re: Decimal in macro variable

@Quentin wrote:

That looks like  an un-related problem.  It looks like at some point in the SAS session, you may have submitted a block of code with unmatched quotation marks.  If you get this problem repeatedly, the easiest thing is to exit EG and then restart, and then search your code for unmatched quotation marks.

No need to exit Enterprise Guide.  Just restart the SAS session that Enterprise Guide is using to run the SAS code.

Super User

## Re: Decimal in macro variable

@Tom wrote:

@Quentin wrote:

That looks like  an un-related problem.  It looks like at some point in the SAS session, you may have submitted a block of code with unmatched quotation marks.  If you get this problem repeatedly, the easiest thing is to exit EG and then restart, and then search your code for unmatched quotation marks.

No need to exit Enterprise Guide.  Just restart the SAS session that Enterprise Guide is using to run the SAS code.

But is there an easy way to restart the session?  The best way I have found is to right-click the server and select disconnect, then right-click again and select connect.  I would love it if there was a "restart session" button / menu item I could refer folks to.

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Super User

## Re: Decimal in macro variable

Disconnect/select sounds the same as restart, just in two steps instead of one.  Still better than leaving the application completely and having to restart the application.

Super User

## Re: Decimal in macro variable

%EVAL is for integer evaluations, for floating point you need %SYSEVALF.

Discussion stats
• 11 replies
• 661 views
• 6 likes
• 6 in conversation