Can anyone please help me out with below code:
libname lib1 'E:\SAS Practice Starting';
Data lib1.hospital;
infile datalines dlm='~' dsd;
input patient:$10. hospitalname:$10. location:$8. amount;
datalines;
p001~lotus~hyd~3000
p002~lotus~hyd~5000
p003~rainbow~bng~2000
p004~rainbow~hyd~5000
p005~apolo~gujarat~1500
p006~apolo~gujarat~3000
p007~yasoda~mumbai~2000
p008~yasoda~mumbai~800
p009~global~hyd~5000
p0010~global~hyd~800
p002~lotus~hyd~5000
p003~rainbow~bng~2000
p005~apolo~gujarat~1500
run;
but my actual problem starts in below program i cant able to use like this '&lib.&table' but i can able to use like this 'lib1.&table'. But i want to pass both libraryname and tablename and i want to resolve together.
%macro pp(lib,table,hospitalname);
PROC SQL;
select sum(amount) as Amount,&hospitalname
from &lib.&table
/*where hospitalname='lotus'*/
group by &hospitalname;
QUIT;
%mend;
%pp(lib1,hospital,hospitalname);
%pp;
quik look tells me
from &lib.&table
should be
from &lib..&table
with two .. in between
quik look tells me
from &lib.&table
should be
from &lib..&table
with two .. in between
Thanks a lot
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.