Hello,
I have a data set called dates containing multiple date variables. I created variables d1 to d54 containing these date variables' years.
I woul like to get the id and the "d" variable if the year is not equal to 2017.
I don't know if i'm clear enough.
Thank for help.
Something like this? 🙂
data have;
input ID d1 d2 d3 d4;
datalines;
1 2016 2017 2013 2011
2 2014 2013 2010 2009
3 2013 2011 2017 2008
4 2015 2015 2007 2008
5 2017 2008 2007 2013
;
data want;
set have;
array years[*] d1-d4;
do i = 1 to dim(years);
if years[i] = 2017 then output;
end;
run;
If I understand you correctly, you want a subset of your dataset named dates, that contains the ID and your 'd' variable if neither one of the 54 year variables are equal to 2017? 🙂
Otherwise, please clarify?
Yes, this is what i want.
Thanks.
Something like this? 🙂
data have;
input ID d1 d2 d3 d4;
datalines;
1 2016 2017 2013 2011
2 2014 2013 2010 2009
3 2013 2011 2017 2008
4 2015 2015 2007 2008
5 2017 2008 2007 2013
;
data want;
set have;
array years[*] d1-d4;
do i = 1 to dim(years);
if years[i] = 2017 then output;
end;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.