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

Please see the attachment.

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
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;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

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.

PeterClemmensen
Tourmaline | Level 20
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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 777 views
  • 0 likes
  • 3 in conversation