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

Hi all,

 

i need to put a macro variable (number of obs in a dataset) into the code that send an automatic email with sas.

 

I count the number of obs with this sql:

 

proc sql noprint;
select count(*)
into :count
from lista
;
quit;
%put Count=&count.;

 

and then i need to put &count into the automatic email that i want to send, i tried in this way:

 

filename mymail email
from=("XXX")
to=("XXX")
subject="Daily report"
;

data _null_;
file mymail;
put 'Hi,';
put 'here the daily numbers of record';
put '&count'.;
put 'Ciao';
run;

 

 

Apparently it doesn't working. Could you please help me?

Many thanks,

 

Marco

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

A more efficient way to get the obs count is by using dictionary.tables, as it only reads the dataset header:

proc sql noprint;
select nobs into :count from dictionary.tables
where libname ="WORK" and memname = "LISTA";
quit;

For your question, macro variables are not resolved inside single quotes; use double quotes instead. 

View solution in original post

1 REPLY 1
Kurt_Bremser
Super User

A more efficient way to get the obs count is by using dictionary.tables, as it only reads the dataset header:

proc sql noprint;
select nobs into :count from dictionary.tables
where libname ="WORK" and memname = "LISTA";
quit;

For your question, macro variables are not resolved inside single quotes; use double quotes instead. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 350 views
  • 0 likes
  • 2 in conversation