BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
VCucu
Obsidian | Level 7

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

 

VCucu_0-1619693859221.png

can somebody help me with this ?

thank you very much,

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User
%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;

View solution in original post

3 REPLIES 3
VCucu
Obsidian | Level 7

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;

Kurt_Bremser
Super User
%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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 582 views
  • 0 likes
  • 2 in conversation