I want check wheather exsiting in the dataset, then preform PROC SQL insert into table.
For example check if month 2017-08 not exsiting then
Proc SQL;
Insert into table ...
Are you trying to check for a value in a column, if it doesn't exist insert a new row with the value?
Or are you trying to create a new variable?
If its the first look af an UPDATE statement instead.
Are you trying to check for a value in a column, if it doesn't exist insert a new row with the value?
Or are you trying to create a new variable?
If its the first look af an UPDATE statement instead.
Something like below could do.
data master;
origin='Master';
format myDateVar date9.;
myDateVar='01Aug2017'd;
do i=1 to 10;
output;
end;
run;
data trans;
format myDateVar date9.;
origin='Trans';
i=11;
myDateVar='05Aug2017'd;
output;
i=12;
myDateVar='01Sep2017'd;
origin='Trans';
output;
run;
%let max_month='01Jan1960'd;
proc sql noprint;
select name into:varlist separated by ','
from dictionary.columns where libname='WORK' and memname='MASTER' order by varnum
;
select max(intnx('month',myDateVar,0,'b')) into :max_month
from master
;
insert into master
select &varlist
from trans
where intnx('month',myDateVar,0,'b') > &max_month
;
quit;
Thank you, that works.
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 25. Read more here about why you should contribute and what is in it for you!
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.