Hi,
I have some problems with my macro.
I created all my variables using SAS code (code below). In "schools" variable I want to find only these cases which contain at least one value from "place" variable. Then I want to add to these cases the right values of "opinion" and "country" variables. The results should look like:
you're not SETting anything in your last dataset -
data &data_out;
set
%let i_1 =1;
is this intended? i think you just need to merge the two datasets together:
proc sort data=AAA; by SCHOOLS;
proc sort data=BBB; by place;
data &data_out;
merge BBB(rename=(place=SCHOOLS)) AAA; by place;
No need for any code generation. Just write the code.
data aaa;
input schools: $50.;
datalines;
harvard
only_harvard
cheese_cake_pizza
wse_is_for_you
;
data bbb;
input place: $10. opinion: 2. country: $10.;
datalines;
Harvard 8 usa
oxford 8 uk
wse 9 france
;
proc sql ;
create table want as
select a.schools,b.opinion,b.country
from aaa a inner join bbb b
on find(a.schools,b.place,'it')
order by 1,2,3
;
quit;
proc print data=want;
run;
Obs schools opinion country 1 harvard 8 usa 2 only_harvard 8 usa 3 wse_is_for_you 9 france
Before writing a macro that generates code, you should have an example of working code similar to what the macro should generate.
Your macro is generating
set find(schools,"&zm1") >0
so SAS thinks that "find" is the name of a data set. The parenthesis indicates that a data st option is to follow, but "schools" is not the name of a data set option.
What working code do you want to generate?
Modifiers. Read the documentation.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.