I have a data set with 1000 observations. I want to only print out the last observation. Using the following:
proc print data=apple(firstobs = 1000 obs = 1000);
run;
I can get the last observation. But I have to know in advance that my data set has 1000 observations. How do I do this without knowing this?
There are many ways you could do this. Here are two:
This just reads the number of observations into a macro variable, and then use that to specify the first observation. (Note that
var1refers to a variable in your data.)Another approach would be to create a data view that only keeps the last observation and then print that: