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

Here am creating a macro  here am creating two datasets x1 x2 from s1 s1 since i cud not access s1  s2 directly in proc sql

in macro,even in this way also  i cud  nt get the correct result,am getting error   ''File WORK.RUN.DATA does not exist''

.
              

%macro test_(test_,s1,s2);
data x1;
set &s1
run;

data x2;
set &s2;
run;

proc sql ;
create table &test_ as
select x1.classifications, x1.VSSTRESN as Active,
x2.VSSTRESN as placebo,sum(x1.VSSTRESN,x2.VSSTRESN ) as total
from x1,x2 where x1.classifications=x2.classifications;
quit;

%mend;

even i cud nt access  the data in the following way also

proc sql ;
create table &test_ as
select &s1.classifications, &s1.VSSTRESN as Active,
&s2.VSSTRESN as placebo,sum(&s1.VSSTRESN,&s2.VSSTRESN ) as total
from &s1,&s2 where &s1.classifications=&s1.classifications;
quit;

 

 

%test_(test100,r1,r2);

 

 

cup u pls help me out.

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

You have situations where you are referring to a macro variable, and attempting to append text after it.  For example:

 

&s1.classifications

 

That's incorrect.  The dot actually delimits the name of the macro variable, so where you hope to generate:

 

r1.classifications

 

You are actually generating:

 

r1classifications

 

In order to get r1.classifications, you need two dots:  one to delimit the name of the macro variable, and a second dot becomes text following the macro variable value:

 

&s1..classifications

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Can you attach the SASLOG so we can see not just this macro but the steps before? This error sometimes is caused by a missing semicolon somewhere, but SAS is looking for a dataset named RUN and it doesn't find it.

 

Agreeing with @Kurt_Bremser, writing in proper English would also help.

--
Paige Miller
Reeza
Super User

And from @PaigeMiller comment your first data step is missing a semicolon. 

 

 

PaigeMiller
Diamond | Level 26

@Reeza wrote:

And from @PaigeMiller comment your first data step is missing a semicolon. 

 

 


Even though I knew that was the problem, I failed to see the missing semicolon!

--
Paige Miller
Astounding
PROC Star

You have situations where you are referring to a macro variable, and attempting to append text after it.  For example:

 

&s1.classifications

 

That's incorrect.  The dot actually delimits the name of the macro variable, so where you hope to generate:

 

r1.classifications

 

You are actually generating:

 

r1classifications

 

In order to get r1.classifications, you need two dots:  one to delimit the name of the macro variable, and a second dot becomes text following the macro variable value:

 

&s1..classifications

ccarel
Fluorite | Level 6

Try this: 

 

%macro test_(test_,s1,s2);
data x1;
set &s1; /*semi-colon was missing*/
run;

data x2;
set &s2;
run;

proc sql ;
create table &test_ as
select x1.classifications,
x1.VSSTRESN as Active,
x2.VSSTRESN as placebo,
sum(x1.VSSTRESN,x2.VSSTRESN ) as total
from x1,x2
where x1.classifications=x2.classifications;
quit;

%mend;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 1239 views
  • 1 like
  • 6 in conversation