Gola1
Gola1

Reputation: 1

How can i add a new date column to an existing table in sas

I want to go back 6mo from existing date and tried tbis but gives me the additional column NewDate with no values.

DATA temp;
SET  Have -- existing table
NewDate: Intx('Month',Date, -6)
run;

Upvotes: 0

Views: 648

Answers (1)

Reeza
Reeza

Reputation: 21264

  1. Missing semicolon on SET statement
  2. DATE() is a function, you require the parenthesis
  3. You need to use equal signs for assignment operations, not colon.
  4. You're missing the fourth parameter for the INTNX() function - the alignment. What do you want that to be? I set it to same but please review the documentation. Also note that the documentation has usage examples that you can follow, if you scroll to the bottom of the page.

Here's a video tutorial on the general concepts about creating a new variable.

data class;
set sashelp.class;

New_Date = intnx('month', date(), 6, 's');
run;

Upvotes: 1

Related Questions