BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Paul_NYS
Obsidian | Level 7

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;

1 ACCEPTED SOLUTION

Accepted Solutions
AncaTilea
Pyrite | Level 9

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);

Smiley Happy

View solution in original post

2 REPLIES 2
AncaTilea
Pyrite | Level 9

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);

Smiley Happy

Paul_NYS
Obsidian | Level 7

Thank you Anca. It is usually something like this.

Paul

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1173 views
  • 0 likes
  • 2 in conversation