BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
joon1
Quartz | Level 8

Dear Madam/Sir,

 

I would like to define future years (t1 through t5) after the event year (cartel_eyear). The code using intnx function does not work.

 

lead_t1=intnx(year, cartel_eyear, 1);

lead_t2=intnx(year, cartel_eyear, 2);

lead_t3=intnx(year, cartel_eyear, 3);

lead_t4=intnx(year, cartel_eyear, 4);

 

Any help will be highly appreciated.

 

Sincerely,

Joon1

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

The first argument of intnx needs to be quoted (if you don't have a variable containing the interval), the second argument must be a sas date. Check your data!

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

What are typical values of the variable CARTEL_EYEAR? Please also show us the PROC CONTENTS output for this variable.

--
Paige Miller
maguiremq
SAS Super FREQ

Are you putting quotes around year in the INTNX function?

andreas_lds
Jade | Level 19

The first argument of intnx needs to be quoted (if you don't have a variable containing the interval), the second argument must be a sas date. Check your data!

joon1
Quartz | Level 8

Thanks for your kind reply. Data structure doesn't have date. So this function cannot be used.

ballardw
Super User

Doesn't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the "</>" to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "</>" icon or attached as text to show exactly what you have and that we can test code against.

 

From your code I expect one or more of the following to appear in your LOG:

 

1: NOTE: Numeric values have been converted to character
values at the places given by: (Line):(Column). 

The above will appear if you have no variable currently in your data set named Year, or Year exists but is a numeric value

 

2: NOTE: Argument 1 to function INTNX() at line NNN
column ZZ is invalid.

The above is going to appear because year either is blank, previously no value assigned, or attempts to use a value like 2023 as an interval for the function.

Leading to:

3: NOTE: Mathematical operations could not be performed at the following
places. The results of the operations have been set to missing
values.

because what ever Year resolved to was not a valid interval.

 


@joon1 wrote:

Dear Madam/Sir,

 

I would like to define future years (t1 through t5) after the event year (cartel_eyear). The code using intnx function does not work.

 

lead_t1=intnx(year, cartel_eyear, 1);

lead_t2=intnx(year, cartel_eyear, 2);

lead_t3=intnx(year, cartel_eyear, 3);

lead_t4=intnx(year, cartel_eyear, 4);

 

Any help will be highly appreciated.

 

Sincerely,

Joon1


 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 763 views
  • 0 likes
  • 5 in conversation