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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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