BookmarkSubscribeRSS Feed
eap
Obsidian | Level 7 eap
Obsidian | Level 7

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.





.

 

 

3 REPLIES 3
Patrick
Opal | Level 21

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.

eap
Obsidian | Level 7 eap
Obsidian | Level 7

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2397 views
  • 3 likes
  • 3 in conversation