BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ksharp
Super User
You didn't post the output when T1.Var1=T2.Var2  yet ?




DATA Data201606;
    LENGTH
        Var1             $ 14
        Var2             $ 14
        WholeBunchOfVars_201606 $ 24 ;
    FORMAT
        Var1             $CHAR14.
        Var2             $CHAR14.
        WholeBunchOfVars_201606 $CHAR24. ;
    INFORMAT
        Var1             $CHAR14.
        Var2             $CHAR14.
        WholeBunchOfVars_201606 $CHAR24. ;
    INFILE DATALINES4
        DLM='7F'x
        MISSOVER
        DSD ;
    INPUT
        Var1             : $CHAR14.
        Var2             : $CHAR14.
        WholeBunchOfVars_201606 : $CHAR24. ;
DATALINES4;
42001223829005420012238211001913672811803603960
42001223829005420012238291001913672811803603960
42001223829005420012238221001913672811803603960
42005537849003420055378411001728228741505881940
42000000420200 149282958163677760150000
42000001251100 137224761123272858132500
42000002571100 115006036153103523280000
42000002992100 176705643184314704200000
42000003721100 134284160134284151225000
;;;;

DATA Data201607;
    LENGTH
        Var1             $ 14
        Var2             $ 14
        WholeBunchOfVars_201607 $ 24 ;
    FORMAT
        Var1             $CHAR14.
        Var2             $CHAR14.
        WholeBunchOfVars_201607 $CHAR24. ;
    INFORMAT
        Var1             $CHAR14.
        Var2             $CHAR14.
        WholeBunchOfVars_201607 $CHAR24. ;
    INFILE DATALINES4
        DLM='7F'x
        MISSOVER
        DSD ;
    INPUT
        Var1             : $CHAR14.
        Var2             : $CHAR14.
        WholeBunchOfVars_201607 : $CHAR24. ;
DATALINES4;
42001223829005420012238221001913672811803603960
42001223829005420012238211001913672811803603960
42001223829005420012238291001913672811803603960
48073274008100...50000
48077274928100...150000
48120011318100...200000
48097297288100...200000
48001314298100...250000
48035295388100...575000
48089429268100...600000
48001012248100...600000
48075642348100...700000
42026909980100.000000000.25000
42001115759100.000000000145868575112500
42014081290100.00000000015346509325000
48000000048500.001241385.50000
48000000048400.001241385.150000
;;;;


data want;
 if _n_=1 then do;
  if 0 then set Data201607;
  declare hash h1(dataset:'Data201607',multidata:'y');
  h1.definekey('Var1','Var2');
  h1.definedata('WholeBunchOfVars_201607 ');
  h1.definedone();
  
  declare hash h2(dataset:'Data201607',multidata:'y');
  h2.definekey('Var2');
  h2.definedata('WholeBunchOfVars_201607 ');
  h2.definedone();
 end;
call missing(of _all_);
set Data201606;
 rc=h1.find();
 if rc=0 then do;
  do while(rc=0);
   output;
   rc=h1.find_next();
  end;
 end;
  else do;
         rx=h2.find(key:var1);
         if rx=0 then do;
           do while(rx=0);
            output;
            rx=h1.find_next();
           end;
         end;
         else output;
        end;
drop rc rx;
run;



sleretrano
Quartz | Level 8
I didn't post the output because I don't really care what the output looks like. What matters to me is the join condition.
This seems to do what I want.
Thank you very much.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 16 replies
  • 3748 views
  • 3 likes
  • 3 in conversation