Hello All,
I am trying to create a list where a certain string is deleted from a string list.
for example: considering the third row in the table below where year=2005,2007, the value 2005,2007 should be deleted from year_list and with end result being "2006,2008,2009,2010,2011"
The original dataset looks like this:
year
year_list
2005
2005,2006,2007,2008,2009,2010,2011
2005,2007
2005,2006,2007,2008,2009,2010,2011
2008,2011
2005,2006,2007,2008,2009,2010,2011
proc sql;
create table have (year VARCHAR(1000), year_list VARCHAR(1000));
insert into have values('2005','2005,2006,2007,2008,2009,2010,2011');
insert into have values('2005,2007' '2005,2006,2007,2008,2009,2010,2011');
insert into have values('2008,2011' '2005,2006,2007,2008,2009,2010,2011');
run;
The "want" variable is what i require as output - as shown in the following table (with code below):
year
year_list
want
2005
2005,2006,2007,2008,2009,2010,2011
2006,2007,2008,2009,2010,2011
2005,2007
2005,2006,2007,2008,2009,2010,2011
2006,2008,2009,2010,2012
2008,2011
2005,2006,2007,2008,2009,2010,2011
2005,2006,2007,2009,2010
proc sql;
create table want (year VARCHAR(1000), year_list VARCHAR(1000), want_list VARCHAR(1000));
insert into want values('2005','2005,2006,2007,2008,2009,2010,2011','2006,2007,2008,2009,2010,2011');
insert into want values('2005,2007' '2005,2006,2007,2008,2009,2010,2011','2006,2008,2009,2010,2012');
insert into want values('2008,2011' '2005,2006,2007,2008,2009,2010,2011','2005,2006,2007,2009,2010');
run;
Any help would be appreciated.
Thank you.
... View more