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

Hello,

 

I am a new SAS coder working on a homework problem that has stumped me. The question is: Write SAS code which will read in 10 observations from the ‘SASHelp.Cars’ data set, starting with the 70th observation.

 

Below is the code I wrote for my answer:

DATA        WORK.Illus;

         SET  SASHelp.Cars (FIRSTOBS = 70 OBS = 10);

            RUN;

 

However, when I run this code, my log gives me an error and two warnings:

 Errors (1)
 Warnings (2)
 Notes (2)
 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         DATAWORK.Illus;
 70         SETSASHelp.Cars(FIRSTOBS = 70OBS = 10);
 ERROR: FIRSTOBS option > OBS option - no data to read from file SASHELP.CARS.
 71         RUN;
 
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.ILLUS may be incomplete.  When this step was stopped there were 0 observations and 0 variables.
 WARNING: Data set WORK.ILLUS was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              530.93k
       OS Memory           21152.00k
       Timestamp           10/26/2023 07:03:03 PM
       Step Count                        42  Switch Count  0
       Page Faults                       0
       Page Reclaims                     52
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 
 72         
 73         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 83 

What am I missing? Thanks for any help.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
 70         SETSASHelp.Cars(FIRSTOBS = 70OBS = 10);
 ERROR: FIRSTOBS option > OBS option - no data to read from file SASHELP.CARS.

There are two problems here ... first is that there is no space after FIRSTOBS=70 (although strangely that doesn't seem to be an error)

 

The second is explained by the ERROR message. You can't have FIRSTOBS > OBS, so you must have OBS to be greater than or equal to FIRSTOBS. With that hint, what do you think OBS should be here?

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
 70         SETSASHelp.Cars(FIRSTOBS = 70OBS = 10);
 ERROR: FIRSTOBS option > OBS option - no data to read from file SASHELP.CARS.

There are two problems here ... first is that there is no space after FIRSTOBS=70 (although strangely that doesn't seem to be an error)

 

The second is explained by the ERROR message. You can't have FIRSTOBS > OBS, so you must have OBS to be greater than or equal to FIRSTOBS. With that hint, what do you think OBS should be here?

--
Paige Miller
BLT2023
Calcite | Level 5

Oh! 79? FIRST OBS = 70, +9 gives me 10 observations. Got it. Thank you so much!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 2798 views
  • 0 likes
  • 2 in conversation