BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
aaaaa34
Calcite | Level 5
Hi,

What does by option do in:
data aaa;
set bbb;
by var1 var2;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@aaaaa34 wrote:

What does by option do in:
data aaa;
set bbb;
by var1 var2;
run;

In this case, the BY statement with a single dataset listed in the SET statement does almost nothing. It does allow FIRST.  and LAST. variables to be created and used, but your code doesn't use them, so essentially BY does nothing in your code.

--
Paige Miller

View solution in original post

3 REPLIES 3
aaaaa34
Calcite | Level 5
 
PaigeMiller
Diamond | Level 26

@aaaaa34 wrote:

What does by option do in:
data aaa;
set bbb;
by var1 var2;
run;

In this case, the BY statement with a single dataset listed in the SET statement does almost nothing. It does allow FIRST.  and LAST. variables to be created and used, but your code doesn't use them, so essentially BY does nothing in your code.

--
Paige Miller
Kurt_Bremser
Super User

@aaaaa34 wrote:
Hi,

What does by option do in:
data aaa;
set bbb;
by var1 var2;
run;

It forces a sort condition by var1 var2. If a deviation from the sort order is encountered during execution, the step will terminate with an ERROR.

Other than that, the by statement in your code has no effect, as neither first. or last. is used.

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
  • 877 views
  • 3 likes
  • 3 in conversation