BookmarkSubscribeRSS Feed
swatipriya
Calcite | Level 5

Hi All,

 

I am a beginner in SAS. Can anyone please help me out on this.

 

1) As per my understanding FIRSTOBS will give the starting point for processing But in the below example, it is giving weird output. FIRSTOBS is working fine when I have used it with the SAS datasets.

Please let me know how FIRSTOBS work in DATALINES.

In the below example if I am decreasing the value of FIRSTOBS, output is changing in different manner.

If I am mentioning FIRSTOBS=4 in the below example, it is throwing error i.e. FIRSTOBS option > number of observations in WORK.DEMO. Here no of observations is 6 which is greater than FIRSTOBS i.e.4 then why it is throwing error?

Code:- 

OPTIONS FIRSTOBS=3 ;
DATA DEMO;
INPUT PID AGE GEN$ NAME$;
DATALINES;
1 23 M cdjdjdc
2 29 F kjkjvnvk
3 12 M vjbdkj
1 23 M vvl
1 23 M vnv
2 29 F vvkj
;
RUN;
PROC PRINT DATA=DEMO;
RUN;

 

Result:- I have attached the output i.e. Output_1Output 1.PNG

 

2)MISSOVER in INFILE:- Will it replace only the last missing variable value with period sign ?

 

1 REPLY 1
Astounding
PROC Star

In reverse order ...

 

MISSOVER sets to missing as many variables as needed.  If your INPUT statement runs out of data with 1 varaible remaining to be found, it sets that one variable to missing.  If it runs out of data with 2 variables left to be found, it sets to missing both variables.  So as many variables as needed (and that can vary from line to line) get set to missing.

 

For your first question, you need to realize that FIRSTOBS=3 applies to both steps.  For the DATA step, it starts reading with the third line of data.  That creates a data set with 4 observations.  Then for PROC PRINT, FIRSTOBS=3 also applies.  So of the 4 observations in your data set, it starts printing with the third observation.

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

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
  • 1 reply
  • 699 views
  • 0 likes
  • 2 in conversation