Hello,
Since you want to run three seperate queries, I suggest you generate the code that you need to be executed with a datastep. You could either write the code to a file that you could then %INCLUDE to execute it, or use CALL EXECUTE() to store them in a temporary buffer and they wil execute after your datastep terminates.
Here is an example of writing the code to a temporary :
filename torun temp;
data want;
infile datalines;
input customer : $10. start_date : $7. end_date : $7. ;
datalines;
customer1 21Jan20 30Jan20
customer2 18Feb20 03Mar20
customer3 13Feb20 22Feb20
;
run;
data _null_;
file torun;
set want;
put "****** QUERY FOR CUSTOMER : " customer " ******;";
put "proc sql; " / "create table " customer " as" / " select sample.numbered, result.value, sample.sampled_date, sample.area,result.name";
put " from employer.sample, employer.result" / " where sample.numbered=result.numbered and" / " sample.sampled_date between ";
put "'" start_date +(-1) "'d and" ;
put "'" end_date +(-1) "'d" ;
put " and sample.area in ('a','b')" / " and result.name = 'Colour';" / " quit;";
run; * %include torun;
After running this you could open a new program editor and run this command in the command line box "inc torun" that will include that temporary file and you can check the generated code. If it looks fine you could simply uncomment the last line and the generated code will be execute upon submit.
... View more