i am somewhat new to sas, so what i want to do is execute some sql only on a certain month. so i want...
proc sql;
update table
set field='Y';
;
to run in a larger program only when the month is january. i am sure it is a fairly easy solution, just having trouble finding the right one. i am using sas eg 7.1 tyi.
thanks
First, you will need working PROC SQL code. I leave that to you as a separate issue. For a short program like you have illustrated, here is an easy way:
data _null_;
if month(today())=1 then call execute(
"proc sql;
update table
set field='Y';
;"
);
run;
First, you will need working PROC SQL code. I leave that to you as a separate issue. For a short program like you have illustrated, here is an easy way:
data _null_;
if month(today())=1 then call execute(
"proc sql;
update table
set field='Y';
;"
);
run;
I am not quite sure if you want to conditionally execute Proc Sql or if you only want to process some records within a data set based on the value of a variable in the data set.
yeah, that worked out great but while i was waiting i also wroote a macro to do that same thing...
%let mnth=%sysfunc(month(%sysfunc(today())));
%macro monthtest;
%if &mnth^=4 %then %do;
proc sql;
select * from TABLE where ID<=100;
%end;
%else %if &mnth=4 %then %do;
proc sql;
select * from TABLE where 100<=ID<=200;
;
%end;
%mend monthtest;
run;
%monthtest
run;
...and to the other questions, what i needed to do was based on whether it was jan or not, if so i needed to mark some delete=y under 2 certain conditions of other columns in the data.
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.
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.