Hi Please help my query.
I am using SAS studio. I have been trying to find a serial number match between two table and update the values of the numbers that match in a new column
Table1:
ser_no x1 x2..
Table2
ser_num x3 x4..
If the ser_no from table1 is present in table 2 (ser_num column) then fill the same value in a new column 'Comparison' in Table 1.
This is equivalent to =VLOOKUP(G1,$J:$J,1,0) G is ser_no (table1) J is ser_num from table2
I tried creating the entire column of table 2 in a macro variable.But nothing seems to work.
data testing;
if _n_ eq 1 then do;
if 0 then set table2;
declare hash h(dataset:'table2');
h.definekey('x3','x4');
h.definedata('ser_num');
h.definedone();
end;
set table1;
run;
Please show test data, in the form of a datastep. It is not possible to diagnose a problem with a data based programming language without seeing data. At a rough guess, I would just merge the two datasets together e.g.
data want; set have1 have2; by idvar; combined_var=coalsecec(varfromhave1,varfromhave2); run;
There are a lot of assumptions in there, both sorted by idvar, both has idvar, etc. Again, without seeing data I couldn't possibly guess what you have.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.