Today is: 29.04.2021
I would like to write a code
1) create a variable based on currentdate generation = 202104 (yyyymm - in our example)
2) search the value from 1 and compare the "server" table latest ID Load value (biggest) = 3 (in our example) with the "local" table latest ID Load value (biggest) =2 (in our example)
3) if a newer version (bigger) value on "server" then i will run a specific macro
can somebody help me with this ?
thank you very much,
%macro yourmac(mandant,generation,s_id,l_id);
%put &=mandant. &=generation. &=s_id. &=l_id.;
%mend;
%put DATA server;
INPUT mandant generation id;
CARDS;
196 202103 1
196 202103 2
196 202104 1
196 202104 2
196 202104 3
;
DATA local;
INPUT mandant generation id;
CARDS;
196 202104 2
;
data want;
merge
server (in=s)
local (
in=l
rename=(id=l_id)
)
;
by mandant generation;
if l and last.generation
then if id > l_id
then call execute(cats('%nrstr(%yourmac(',mandant,",",generation,",",id,",",l_id,'))'));
run;
Please supply example data in usable form (data steps with datalines). We cannot run code against pictures.
DATA server; INPUT mandant generation id; CARDS; 196 202103 1 196 202103 2 196 202104 1 196 202104 2 196 202104 3 ; RUN; DATA local; INPUT mandant generation id; CARDS; 196 202104 2 ; RUN;
%macro yourmac(mandant,generation,s_id,l_id);
%put &=mandant. &=generation. &=s_id. &=l_id.;
%mend;
%put DATA server;
INPUT mandant generation id;
CARDS;
196 202103 1
196 202103 2
196 202104 1
196 202104 2
196 202104 3
;
DATA local;
INPUT mandant generation id;
CARDS;
196 202104 2
;
data want;
merge
server (in=s)
local (
in=l
rename=(id=l_id)
)
;
by mandant generation;
if l and last.generation
then if id > l_id
then call execute(cats('%nrstr(%yourmac(',mandant,",",generation,",",id,",",l_id,'))'));
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.