Hi, SAS Community.
I'm trying to subset a dataset so that it includes only those observations that have the variable "year" coded as 2008, but either nothing happens or my output data table is devoid of observations for all variables.
My data looks something like this:
id var1 var2 var3 year
1 25 38 yes 2008
2 16 72 yes 2016
3 3 51 no 2008
4 12 16 yes 2016
etc.
The following code creates a dataset with all variable columns but no values:
data subset;
set dataset;
where year=2008;
run;
The following code creates a dataset with no observations deleted (i.e., dataset = subset):
Data is proprietary and I don't feel comfortable sharing it, which is why I posed the question the way I did. In any event, the problem has been solved. I thought I had indicated that. Thanks.
Give us the LOG !
Probably year is a character variable (or something else that should be obvious from the LOG).
Koen
Probably, it would help to see the log, as said by @sbxkoenk . And we need to see the ENTIRE log for you DATA step, not portions, not the errors only, ALL OF IT for this DATA step.
My data looks something like this:
But you can help yourself @Kelly_K get faster and better answers, and help us help you, by providing us your exact data (or a portion of it), rather than "... something like this". You need to provide (a portion of) your data as working SAS data step code, emphasis on working, which you can type in yourself or follow these instructions. This should be standard operating procedure, in this thread, and from now on whenever you post a question here.
Data is proprietary and I don't feel comfortable sharing it, which is why I posed the question the way I did. In any event, the problem has been solved. I thought I had indicated that. Thanks.
@Kelly_K Then please post fake data with fake variable names which has the exact same data set structure as the real data. Post it as WORKING data step code. We will consistently ask you to provide data in that format, so please just go ahead and provide data in that format from now on. You will be helping us, which helps you.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.