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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.