Learning SAS? Welcome to the exclusive online community for all SAS learners.

How to retain only some variables from dataset A and some variables from dataset B when merging them horizontally? Comparison of alternative SAS syntaxes and explanations of their respective strong points.

Reply
Occasional Contributor
Posts: 12

How to retain only some variables from dataset A and some variables from dataset B when merging them horizontally? Comparison of alternative SAS syntaxes and explanations of their respective strong points.

Hello,

I am trying to understand the named question above. I am posting it below for convenience:

How to retain only some variables from dataset A and some variables from dataset B when merging them horizontally?

Comparison of alternative SAS syntaxes and explanations of their respective strong points.


I am expected to format my answers by including the following:


a) find out, for each issue, between 3 and 5 interesting documentation sources (eg SAS User's manuals, SAS course notes, archives of the SAS-L list, forums like SAS communities, SUGI papers, blogs on SAS, courses offered on university sites,...) explaining how to deal efficiently with this issue

b) for each issue, give all the possible answers, explaining their relative characteristics and advantages, indicating the sources where the information was found.

c) for each issue, the final synthesis should be very clear, proofread and potentially useful for people looking for explanations about the way to deal with the data management issues at stake, using SAS. It implies that, for each issue, the assignment should start with a brief explanation of what the issue is, then explain how to deal with this issue, and end with at least two short examples (easy to understand and to replicate) with comments between /* */.

I appreciate comprehensive help, as these answers will enable better understanding and better performance on my upcoming exam.

Kind regards!

Trusted Advisor
Posts: 1,624

Re: How to retain only some variables from dataset A and some variables from dataset B when merging them horizontally? Comparison of alternative SAS syntaxes and explanations of their respective strong points.

Well, you've asked for a huge amount of detail, and I don't really feel like I have the time or interest to answer the question at the level of detail that you want.

Fortunately, if you want documentation sources, there's the SAS User's Manual, online help and (gasp!) Google

There are really two ways to do this. When merging the datasets, you can use either the KEEP= dataset option, or the DROP= dataset option.

Which is better? Well, it all depends on how many variables you want to KEEP, or how many variables you want to DROP. But whether you use KEEP or DROP, if you do it properly, the end result is the same. Globally, there is no reason to prefer one over the other, although in very specific situations one may be less typing than the other.

By the way, I agree with Reeza, this sounds a lot like homework, and I doubt anyone here will provide the answers for you at the level of detail you are asking for.

However, if you have specific follow-up questions, or you have code where it's not working properly, we'd be happy to help.

Ask a Question
Discussion stats
  • 1 reply
  • 233 views
  • 0 likes
  • 2 in conversation