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

Thank You

 

Tom
Super User Tom
Super User

If you want to make the macro more flexible add parameters.  You can include logic to add a default value. 

You can have SAS add the default value for you if you make the parameters non-positional.

%macro patient_obs(dsn=&syslast);
....
  from &dsn 
....
%mend ;

Or you can add your own logic.

%macro patient_obs(dsnt);
%if 0=%length(&dsn) %then %let dsn=&syslast;
%if not %sysfunc(exist(&dsn)) %then %do;
  %put &=dsn not found.;
%end;
....
  from &dsn 
....
%mend ;
manya92
Fluorite | Level 6

in this code  :- what is INTO:npatients trimmed nobs trimmed for ? i dont know what trimmed means in this case

%macro patient_obs() ;
%global nobs npatients ;
proc sql noprint;
  select
         count(enrolid) format=32.
       , count(N) format=32.
    into 
         :npatients trimmed 
       , :nobs trimmed
  from &syslast. 
  ;
quit ;
%put Dataset &syslast. has &nobs. observations and &npatients. patients ;
%mend patient_obs;
Tom
Super User Tom
Super User

Apparently the new SAS 9.4 documentation is defective.

Look at the SAs 9.3 documentation instead.

 

INTO clause

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
  • 18 replies
  • 1463 views
  • 3 likes
  • 5 in conversation