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

Hi all SAS Users,

 

This morning, I read a set of code as below, I do not understand the underlying reason of the code

proc sort data=my.keepvar_1999_2000 (keep=LOC)
	out= want NODUPKEY;
	by LOC;
run;

I do not know why they keep LOC while they sort by LOC in this case (LOC is a character variable denoted the country) . Could you please explain it to me?

Warm regards.

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

The main purpose of selecting specific variables from the source data would be to reduce the size the output data set to what the coder only needs to use later.

A secondary reason could be to reduce the size of the temporary data set(s) that Proc Sort generates while executing.

 

If you only need one variable but the data set has 100 more variables then disk space and memory is needed in execution for stuff that you don't want. So the code would run faster using less resources.

View solution in original post

2 REPLIES 2
ballardw
Super User

The main purpose of selecting specific variables from the source data would be to reduce the size the output data set to what the coder only needs to use later.

A secondary reason could be to reduce the size of the temporary data set(s) that Proc Sort generates while executing.

 

If you only need one variable but the data set has 100 more variables then disk space and memory is needed in execution for stuff that you don't want. So the code would run faster using less resources.

SASKiwi
PROC Star

The obvious purpose to me is to create an ascending order list of the unique values in variable LOC.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 681 views
  • 2 likes
  • 3 in conversation