How can i simplify this code (macro or loop): Proc SQL; Create Table Test as select distinct Count(distinct case when 2005 GE year(start) and 2005 LE year(end) then person else . end) as person_count_2005 , Count(distinct case when 2006 GE year(start) and 2006 LE year(end) then person else . end) as person_count_2006 , Count(distinct case when 2007 GE year(start) and 2007 LE year(end) then person else . end) as person_count_2007 , Count(distinct case when 2008 GE year(start) and 2008 LE year(end) then person else . end) as person_count_2008 , Count(distinct case when 2009 GE year(start) and 2009 LE year(end) then person else . end) as person_count_2009 , Count(distinct case when 2010GE year(start) and 2010 LE year(end) then person else . end) as person_count_2010 , Count(distinct case when 2011 GE year(start) and 2011 LE year(end) then person else . end) as person_count_2011 from data; quit; This is example only for the years 2005 to 2011, but i want count person for more years. Thank you for your effort! Dynamike
... View more