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

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

quik look tells me

 

from &lib.&table

 

should be

 

from &lib..&table

 

with two .. in between 

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

quik look tells me

 

from &lib.&table

 

should be

 

from &lib..&table

 

with two .. in between 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 799 views
  • 0 likes
  • 2 in conversation