BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
xxformat_com
Barite | Level 11

Hi,

 

As far I'm aware of, the only way to be informed that two variables of the same name are used in a merge without being listed in the by statement is to display information messages in the log using options msglevel=i;.

- The option is not in the default setting.

- The message is not really easy to notice (black color)

- Other messages which are usually not that relevant popup on the way with this option.

 

Question 1 : is there already a request to get a global option similair to mergenoby for this specific issue?

Question 2: if not, how to request such new feature?

Question 3: I would go for a global option called mergeoverwrite= with WARN by default. Would you have a better suggestion for it.

 

 

data one;
   key=1; x=1; output;
   key=2; x=2; output;
run;


data two;
   key=1; x=5; output;
   key=2; x=6; output;
run;

*options mergeoverwrite=WARN;
options msglevel=i;

data demo;
   merge one two;
   by key;
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If you look at the top of the forum where there is the menu of Community Learn Programming etc, the drop down for Community will show an option of "SASWare Ballot". That is the place here to make such suggestions.

 

Considering the amount of code written over the years that is intentionally using the current behavior of the data step Merge, I strongly doubt there would be widespread support for making that proposed option the default. I know I don't want to see it in the logs for the dozens of projects I use Merge in.

View solution in original post

3 REPLIES 3
ballardw
Super User

If you look at the top of the forum where there is the menu of Community Learn Programming etc, the drop down for Community will show an option of "SASWare Ballot". That is the place here to make such suggestions.

 

Considering the amount of code written over the years that is intentionally using the current behavior of the data step Merge, I strongly doubt there would be widespread support for making that proposed option the default. I know I don't want to see it in the logs for the dozens of projects I use Merge in.

xxformat_com
Barite | Level 11
Thank you @ballardw for SASWare Ballot.

If the global option is added, that would already a great help, even with nowarn.

I was just thinking that programs overwriting variables values by other variables values while merging would be something done by mistake, not intentionally. At least that's the way I program. That's way I would find useful to be notified, even in old validated programs. It would be similar and less impactful to the global option VARLENCHK. But I may be wrong there.
ballardw
Super User

Every programming language has features that take some experience to realize when you might have an issue.

That's sort of nature of the job. One person's "bug" is another's "feature" and vice versa.

 

One of the languages I worked with had a function that was a sub-string function that looked like:

z = substr(variablename,position1,position2)

or

y = substr(variablename,position1;position2)

 

How long did it take you to determine the difference between those two statements? The same function could return different results depending one whether a comma or semicolon separated the position parameters. One worked like the SAS substr function and returned the string starting at position1 and returned position2 number of characters, the other returned a substr starting at position1 and returned the string ending at that position.

Once you get used to that it is handy but I was always having to check to see which was "number of characters" and which was "ending position" because I had learned a different language prior that did not have that "feature"  and would use the wrong one about half the time. (And ended up only using that in the one class).

 

PIck a data set with 20 numeric variables and calculate the mean, max, min, median, standard deviation, skewness and kurtosis using SQL (or SAS Proc sql). You, the programmer, have to explicity list each summary for each variable, 20*7 references. Proc means you provide the statistic list and the list of variables. If you are summarizing all the numeric variables you don't even need to do that. Different approaches for different languages.

 

Merge is nice for many things. And then you run into multiple data sets with multiple values of the By variables. Then not so nice. So may Proc SQL comes into play. 

 

Finding the better tool is part of the learning process. Have fun.

 

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
  • 378 views
  • 2 likes
  • 2 in conversation