BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KEDWARD50
Calcite | Level 5
proc means data=pg1.np_multiyr noprint;
    var Visitors;
    class Region Year;
    ways 2;
    output out=work.top3list(drop=_freq_ _type_)
           sum=TotalVisitors /*sum total visitors*/
    	   idgroup(max(Visitors) /*find the max of visitors*/
    	   out[3] /*top 3*/
    	   (Visitors ParkName)=); /*output columns for top 3 parks*/
run;

I need help editing this SAS code. 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:
The PG1 folder (if you ran the setup instructions correctly) should have multiple sub-folders (like activities, demos, data, practices and output) and assuming you ran ALL of the setup instructions, your DATA subfolder should have files in it.

The e-learning developers just changed the instructions for SAS OnDemand for Academics on Jan 18th and so, it would be even easier to go back and rerun the startup instructions, just to be sure you have made the data correctly.

There's a video here: https://youtu.be/8sI_UsNvIHE for creating the Programming 1 files using SAS OnDemand for Academics. It steps you through the entire new process.

This is the solution code:
use_np_multiyr.png
It looks like you've got the correct code, so you just need to have the correct LIBNAME statement for PG1 and you need to be sure that your data files were created correctly in the PG1 folder.

 

For SAS OnDemand for Academics, the location should be:

libname pg1 "/home/<youruserid>/EPG194/data";

 

For SAS University Edition, the location should be:

libname pg1 "/folders/myfolders/EPG194/data";

 

But, if you expand the PG1 library in the LIBRARIES pane and you do NOT see data files in the PG1 library, that implies that you did not successfully make the data for the class. There are instructions in the Course Overview and Data Setup section of the course for how to make the data and the video show these same instructions.

 

Cynthia

View solution in original post

15 REPLIES 15
KEDWARD50
Calcite | Level 5

error1.jpgerror2.jpg

These are the error messages received.

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

@KEDWARD50 remove the /* */ that is around your library assignment.

the system needs the libname reassigned.  your first error should clean up the remaining errors.

 

 

KEDWARD50
Calcite | Level 5

I still got the same errors.

Reeza
Super User
Run a proc contents on the data set you're expecting to be there. Currently your challenge is telling SAS where to find the data, all your error stem from that issue. The input data set doesn't exist for some reason.
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

when you run this

 

 

71         libname pg1 "/home/kedward50/EPG194/data";
do you see this
NOTE: Libref PG1 was successfully assigned as follows:
       Engine:        V9
       Physical Name: /home/kedward50/EPG194/data
KEDWARD50
Calcite | Level 5

Yes I do!

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13
1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 70         
 71         proc means data=pg1.np_multiyr noprint;
 72             var Visitors;
 73             class Region Year;
 74             ways 2;
 75             output out=work.top3list(drop=_freq_ _type_)
 76                    sum=TotalVisitors /*sum total visitors*/
 77                idgroup(max(Visitors) /*find the max of visitors*/
 78                out[3] /*top 3*/
 79                (Visitors ParkName)=); /*output columns for top 3 parks*/
 80         run;
 
 NOTE: There were 30652 observations read from the data set PG1.NP_MULTIYR.
 NOTE: The data set WORK.TOP3LIST has 49 observations and 9 variables.
 NOTE: PROCEDURE MEANS used (Total process time):
       real time           0.02 seconds
       user cpu time       0.01 seconds
       system cpu time     0.01 seconds
       memory              8033.70k
       OS Memory           35000.00k
       Timestamp           01/25/2019 10:36:00 PM
       Step Count                        28  Switch Count  2
       Page Faults                       0
       Page Reclaims                     2128
       Page Swaps                        0
       Voluntary Context Switches        210
       Involuntary Context Switches      0
       Block Input Operations            12800
       Block Output Operations           264
       
 
 81         
 82         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 94     

works for me @KEDWARD50 

 

proc contents pg1.np_multiyr;run;

 

The CONTENTS Procedure

The Contents Procedure

PG1.NP_MULTIYR

Attributes

 
Data Set Name PG1.NP_MULTIYR Observations 30652
Member Type DATA Variables 11
Engine V9 Indexes 0
Created   Observation Length 216
Last Modified   Deleted Observations 0
Protection   Compressed NO
Data Set Type   Sorted NO
Label      
Data Representation SOLARIS_X86_64, LINUX_X86_64, ALPHA_TRU64, LINUX_IA64    
Encoding utf-8 Unicode (UTF-8)    

Engine/Host Information

 
Engine/Host Dependent Information
Data Set Page Size 131072
Number of Data Set Pages 51
First Data Page 1
Max Obs per Page 606
Obs in First Data Page 590
Number of Data Set Repairs 0
Filename /home/>>>>>>>/EPG194/data/np_multiyr.sas7bdat
Release Created 9.0401M5
Host Created Linux
Inode Number 2214828782
Access Permission rw-r--r--
Owner Name >>>>>>>
File Size 7MB
File Size (bytes) 6815744

Variables

 
Alphabetic List of Variables and Attributes
# Variable Type Len Format Informat Label
9 Camping Num 8 COMMA12.    
7 Month Num 8 BEST12. BEST12.  
11 OtherCamping Num 8 COMMA12. COMMA12. Concessioner Camping
10 OtherLodging Num 8 COMMA12. COMMA12. Concessioner Lodging
4 ParkName Char 115      
1 Region Char 17 $CHAR17. $CHAR17.  
5 State Char 2 $CHAR2. $CHAR2.  
2 Type Char 28 $CHAR28. $CHAR28.  
3 UnitCode Char 4 $CHAR4. $CHAR4.  
8 Visitors Num 8 COMMA12. COMMA12.  
6 Year Num 8 BEST12. BEST12.  
KEDWARD50
Calcite | Level 5
What am I possibly missing?
KEDWARD50
Calcite | Level 5

In your libraries, is there anything listed under your TOP3LIST?TOP3LIST.jpg

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

first off your PG1 library has noting listed in it based on that your picture doesn't have the little > in front of it.

 

you need to assign PG1 to the correct location that contains the np_multiyr data.

 

 

Reeza
Super User

@KEDWARD50  I'm guessing that you're using your own custom SAS installation. Did you run the programs to set up the data for the course? Was the data for the course created correctly and you've been able to work with it historically?

 

 

 

 

Cynthia_sas
SAS Super FREQ

Hi:
The PG1 folder (if you ran the setup instructions correctly) should have multiple sub-folders (like activities, demos, data, practices and output) and assuming you ran ALL of the setup instructions, your DATA subfolder should have files in it.

The e-learning developers just changed the instructions for SAS OnDemand for Academics on Jan 18th and so, it would be even easier to go back and rerun the startup instructions, just to be sure you have made the data correctly.

There's a video here: https://youtu.be/8sI_UsNvIHE for creating the Programming 1 files using SAS OnDemand for Academics. It steps you through the entire new process.

This is the solution code:
use_np_multiyr.png
It looks like you've got the correct code, so you just need to have the correct LIBNAME statement for PG1 and you need to be sure that your data files were created correctly in the PG1 folder.

 

For SAS OnDemand for Academics, the location should be:

libname pg1 "/home/<youruserid>/EPG194/data";

 

For SAS University Edition, the location should be:

libname pg1 "/folders/myfolders/EPG194/data";

 

But, if you expand the PG1 library in the LIBRARIES pane and you do NOT see data files in the PG1 library, that implies that you did not successfully make the data for the class. There are instructions in the Course Overview and Data Setup section of the course for how to make the data and the video show these same instructions.

 

Cynthia

KEDWARD50
Calcite | Level 5

I'm going to try this now. Thanks you!

KEDWARD50
Calcite | Level 5

Nothing is listed under Top3List

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 15 replies
  • 1641 views
  • 1 like
  • 4 in conversation