BookmarkSubscribeRSS Feed
Zhenmin
Calcite | Level 5

Two tales with 100 unique observations, how much observations after set? How much observation after merge?

3 REPLIES 3
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

well you don't tell very much.

a set statement should give you 100.

a merge statement will give you the number of obs that meet the by statement in you data merge.

ballardw
Super User

@Zhenmin wrote:

Two tales with 100 unique observations, how much observations after set? How much observation after merge?


Actually there is insufficient information to answer this question without 1) the exact code used and 2) the data involved for the merge.

 

Consider the following code:

data junk;
  x=5;
run;

data example;
   set junk junk junk;
run;

The data set Example has 3 records because the data set name Junk is duplicated on the set the statement even though the set Junk only has one record.

Or

data example;
   set junk ;
   do i= 1 to 5;
      output;
   end;
run;

Has 5 records because the OUTPUT statement executes 5 times for each record in Junk.

 

Additionally other code in a data step could add or remove records.

Merge without a BY would have 100 records. But if there is a BY statement you could have anywhere from 100 to 200 depending on the content of the data assuming there are no record filters or anything to create additional records.

 

Zhenmin
Calcite | Level 5

Thank you all and have a nice weekend!

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 921 views
  • 0 likes
  • 3 in conversation