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_1
2)MISSOVER in INFILE:- Will it replace only the last missing variable value with period sign ?
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.
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 25. Read more here about why you should contribute and what is in it for you!
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.