DATA Step, Macro, Functions and more

data step and Year function

Accepted Solution Solved
Reply
Regular Contributor
Posts: 216
Accepted Solution

data step and Year function

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;


Accepted Solutions
Solution
‎01-29-2013 10:23 AM
Super Contributor
Posts: 543

Re: data step and Year function

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


All Replies
Solution
‎01-29-2013 10:23 AM
Super Contributor
Posts: 543

Re: data step and Year function

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

Regular Contributor
Posts: 216

Re: data step and Year function

Posted in reply to AncaTilea

Thank you Anca. It is usually something like this.

Paul

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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