Hi All,
(Sytax #1) I merged two datasets, got no errors and the dataset looks as expected (23 variables).
(Syntax #2) Next I wanted to make the IN= variables permanent. I got no errors but the merged dataset is exactly the same as the previous code where # of variables=23. To test that SAS was functioning I deliberately reversed the variables on either side of the equal sign and got an error.
(Syntax #3) Then I decided to create a ‘Match variable’ with 3 different categories. But the merge dataset is still identical to before and the new match variable was not added to the dataset.
SAS 9.4 recognizes if I insert an error an also if I use the 'If a' or 'If b' options. Condensed synytax is below.
What gives?
(SYNTAX #1)
DATA all_rates;
MERGE archived_data (in=a)
recent_rates1 (in=b);
by procedure_code procedure_type;
run;
NOTE: The data set WORK.ALL_RATES has 17842 observations and 23 variables.
(SYNTAX #2)
DATA all_rates ;
MERGE archived_data (in=a)
recent_rates1 (in=b);
by procedure_code procedure_type;
archived=a;
recent=b;
run;
NOTE: The data set WORK.ALL_RATES has 17842 observations and 23 variables.
(SYNTAX #3)
DATA all_rates ;
MERGE archived_data (in=a)
recent_rates1 (in=b);
by procedure_code procedure_type;
if a and b then match='match';
if a and not b then match='archived';
if b and not a then match='recent';
run;
NOTE: The data set WORK.ALL_RATES has 17842 observations and 23 variables.
.
The only explanation for not getting additional variables is, that these variables already exist in one of your source data sets; else everything looks totally fine with your code.
Kurt's maxim #1 for effective SAS programmers: Know Your Data.
Run proc contents on your input datasets and look at the variable lists.
Hey Guys,
Just wanted to give an update (albeit a little delayed....had lots of traveling). Thanks Kurt and Patrick, I had no idea what approach to take to start investigating. You both put me on a path to think differently about the data.
Well, the culpruit was two-fold. First, I did PROC CONTENTS and found that indeed one dataset had the wrong length and format for one of the sorting variables -not sure why I didn't get a warning or error. Lastly, once that was fixed I got an error about duplicates in the BY variables. Once these were fixed everything worked fine.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.