Reputation: 4763
I want to create a list of years. Since I just need a handful, I do it like this:
create table work.year_range
(YEAR num);
insert into work.year_range
values (2006) values (2007) values (2008) values (2009) values (2010) values (2011)
values (2012) values (2013) values (2014) values (2015) values (2016) values (2017);
but that is clearly ugly. What is the ideomatic way to create a range of numbers in PROC SQL?
Upvotes: 0
Views: 363
Reputation: 3315
you have to use do loop and hard to emulate the same in proc sql;
data year_range;
do year= 2006 to 2017;
output;
end;
run;
Another crude way(not recommended) to do proc sql is to use undocumented monotonic function and using dataset which has more than 11 records as shown below
proc sql;
create tale work.year_range
select 2005 + monotonic() as year
from sashelp.class
where calculated year between 2006 and 2017;
Upvotes: 1