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 

SAS Innovate 2025: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 389 views
  • 0 likes
  • 2 in conversation