Hello
I want to create a new data set that start from observation 3 and take 4 observations.
However in the reslut I get only 2
data ttt;
input ID x;
1 10
2 20
3 30
4 40
5 50
6 60
7 70
8 80
9 90
10 100
;
run;
data new;
set ttt(firstobs=3 obs=4);
run;
As the Firstobs= Options Doc says: "When the FIRSTOBS= data set option specifies a starting point for processing, the OBS= data set option specifies an ending point. The two options are often used together to define a range of observations to be processed. "
Therefore, do this instead
data new;
set ttt(firstobs=3 obs=6);
run;
obs= does not specify the number of observations to be read, but a specific observation number up to which the data is read. So you get observation #3 and observation #4.
Hi @Ronein Easy way to understand is
FIRSTOBS= specifies the first observation to read.
OBS= Last observation to read.
What perhaps confused you is the thought OBS = is the number of observations of read however it is the last observation to read. Also, FirstOBs should never be greater than Obs at all times. Hope this helps
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: