BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
coder1234
Obsidian | Level 7

The question for SAS® Programming 1: Essentials Lesson 03, Section 1; Level 2 Question 6 is the following: 

View the pg1.np_summary table to identify the name and size of the smallest and largest parks.

For the solution, it has the name and size of the smallest and largest park but not the steps. 

 

The question I have is:

Which steps/process was I supposed to take that followed the module?

How am I supposed to identify the ParkName of the Min and Max using the SAS Training/code that has been introduced up to this point?

 

These are just two of the many methods I used for acquiring the MIN and MAX. 

proc univariate data=pg1.np_summary;
var Acres;
run;
proc means data=PG1.NP_SUMMARY MIN MAX;
var Acres ParkName;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
antonbcristina
SAS Super FREQ

Yes, I think the purpose of this section was to explore data using the procedures mentioned in Lesson 3.1. The instructions for that particular Question 2 were very specific to using PROC UNIVARIATE and a visual scan through the data.

 

Now, that does not mean that it is the most efficient way to achieve this. For example, a quick browse through the PROC UNIVARIATE documentation would reveal some helpful additions to the code, like the NEXTOBS=1 option and the ID statement, which when combined, would get us closer to the answer in one step.

 

proc univariate data=pg1.np_summary nextrobs=1; 
	var Acres; 
	id parkname;
run;

antonbcristina_0-1738112578083.png

 

View solution in original post

6 REPLIES 6
antonbcristina
SAS Super FREQ

Hi @coder1234, in the previous question (2b), you were asked to write a PROC UNIVARIATE step to look at the smallest and largest park based on acreage.  From that output, you would be able to identify the observation numbers for those parks. Question 2c) then asks you to look at the original pg1.np_summary dataset and identify the names of those parks based on observation numbers.

coder1234
Obsidian | Level 7

SAS intended the learner to just scroll through the dataset without using SAS coding?

I was hoping there was a SAS code that would generate an output similar to this: 

 

coder1234_0-1738098453756.png

coder1234_1-1738098621699.png

 

 

antonbcristina
SAS Super FREQ

Yes, I think the purpose of this section was to explore data using the procedures mentioned in Lesson 3.1. The instructions for that particular Question 2 were very specific to using PROC UNIVARIATE and a visual scan through the data.

 

Now, that does not mean that it is the most efficient way to achieve this. For example, a quick browse through the PROC UNIVARIATE documentation would reveal some helpful additions to the code, like the NEXTOBS=1 option and the ID statement, which when combined, would get us closer to the answer in one step.

 

proc univariate data=pg1.np_summary nextrobs=1; 
	var Acres; 
	id parkname;
run;

antonbcristina_0-1738112578083.png

 

coder1234
Obsidian | Level 7

This was the option I was looking for! I must have overlooked it thinking it was focusing on extreme observations. 

SAS did go over the code after all,  Challenge Practice: Generating Extreme Observations Output, epg1v203. It didn't occur to me to decrease the nextrobs and that it would show the ID along with it. I appreciate your help and thank you so much for sharing it. It solved my question!

 

quickbluefish
Barite | Level 11
Try sorting it by size. After doing so, how would you select the rows that contain the largest and smallest parks?
coder1234
Obsidian | Level 7

Thank you for your response.

However, I believe the steps you are mentioning are not presented until SAS® Programming 2: Data Manipulation Techniques Lesson 2.

I wanted to get the results via SAS using the techniques that have been previously introduced prior to the Problem/Question. 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 3615 views
  • 6 likes
  • 3 in conversation