Hi Everyone
Whenever I create a data step and use the Year function as it is used below, it never adds the new variable and I don't get an error. I can add it after the fact in another data step, but not in one.
Is there a syntax issue or just can't be done?
Paul
data s0First (keep=cnty_name County place start stop exit filing_cat1 agecat4);
set workep;
if ep1=1 and year(start) in (2006, 2007, 2008, 2009, 2010, 2011)
and filing_cat1 in ("FNN", "FNA", "FVL");
County=cnty_name;
Year=year(start);
if spellage in (0, 1, 2, 3) then agecat4 = 1;
if spellage in (4, 5, 6) then agecat4 = 2;
if spellage in (7, 8, 9) then agecat4 = 3;
if spellage in (10, 11, 12) then agecat4 = 4;
if spellage in (13, 14, 15) then agecat4 = 5;
if spellage in (16, 17) then agecat4 = 6;
if spellage > 17 or spellage eq . or spellage < 0 then agecat4 = 7;
run;
You use a keep statement to the data set you create and Year is not in the list.
data s0First (keep=cnty_name County place start stop exit filing_cat1 agecat4 YEAR);
![]()
You use a keep statement to the data set you create and Year is not in the list.
data s0First (keep=cnty_name County place start stop exit filing_cat1 agecat4 YEAR);
![]()
Thank you Anca. It is usually something like this.
Paul
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.