BookmarkSubscribeRSS Feed
Jaheuk
Obsidian | Level 7

Hi all,

this week I was updating an old sas program.

Several times the developer was MERGING several data sets AND at the same time using xxx.FIRST and yyy.LAST statements.

I never do these things together. I think unexpected results can come up?

AGREE??

GreetZ,

Herman

3 REPLIES 3
Astounding
PROC Star

Herman,

This is just a stage you're going through.  The more you learn about how MERGE works, the less you will see unexpected results.  Eventually, you will know enough about it so that you can anticipate and code around any of the problems.

Typically the case you describe involves the use of a subsetting IF in combination with a BY statement.  A subsetting IF can delete an observation having FIRST.xxx or LAST.yyy equal to 1.  That is likely to give you an undesirable result.

Good luck and don't stop learning.

K_T_
Calcite | Level 5

As far as I can remember you can have some issues using a by when values get retained when you wouldn't expect them to. This can cause problems when an IF statement doesn't give you the value you expect. It does make sense when you think in terms of how the PDV works but it is counter-intuitive and easily catches people out.

deepak_bisht
Calcite | Level 5

Hi Jeheuk,

Can you please provide me with a best example to use first. and last....I've just started learning SAS and want to make my concept clear on first. and last. statement.

Thanks,

Deepak

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1252 views
  • 0 likes
  • 4 in conversation