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 !
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
@SASdevAnneMarie wrote:
Thank you! Why %eval function doesn't work for this macro variable :
%let tx=%eval(&Montant_EU+1) ?
What about this doesn't work?
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
This code doesn't work on my EG, I have this erros :
Can you copy / paste the full code (as part of the full log)?
Thanks,
Koen
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.
@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.
@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.
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.
%EVAL is for integer evaluations, for floating point you need %SYSEVALF.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.