Please see the attachment.
data table1;
input ALC $ 1-21 TAS $ 10-23 ODN $ 25-41 FundingCode $ 43-48;
datalines;
89000001 08919/200243 89303019SEA000002 20EA01
89000001 089X0243 89303019SAU000016 20AU01
89000001 089-17/20-0321 89243419SEE000038 20GO01
89000001 089-17/20-0243 89303019SLM000012 20LM01
89000001 089-X-0319 89243219SNE000007 20ID01
;
data table2;
input ALC $ 1-21 TAS $ 10-23 ODN $ 25-41 FundingCode $ 43-48;
datalines;
20EA01
20AU01
20GO01
20LM01
20ID01
;
data want(drop=rc);
if _N_=1 then do;
declare hash h(dataset:'table1');
h.definekey('FundingCode');
h.definedata('ALC', 'TAS', 'ODN');
h.definedone();
end;
set table2;
rc=h.find();
run;
You can join on the common column, or you can create formats from the columns in the wide dataset, or you can load the wide dataset into a hash object. It depends on dataset sizes and how you process the "small" dataset.
data table1;
input ALC $ 1-21 TAS $ 10-23 ODN $ 25-41 FundingCode $ 43-48;
datalines;
89000001 08919/200243 89303019SEA000002 20EA01
89000001 089X0243 89303019SAU000016 20AU01
89000001 089-17/20-0321 89243419SEE000038 20GO01
89000001 089-17/20-0243 89303019SLM000012 20LM01
89000001 089-X-0319 89243219SNE000007 20ID01
;
data table2;
input ALC $ 1-21 TAS $ 10-23 ODN $ 25-41 FundingCode $ 43-48;
datalines;
20EA01
20AU01
20GO01
20LM01
20ID01
;
data want(drop=rc);
if _N_=1 then do;
declare hash h(dataset:'table1');
h.definekey('FundingCode');
h.definedata('ALC', 'TAS', 'ODN');
h.definedone();
end;
set table2;
rc=h.find();
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.