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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.