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
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!
What are typical values of the variable CARTEL_EYEAR? Please also show us the PROC CONTENTS output for this variable.
Are you putting quotes around year in the INTNX function?
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!
Thanks for your kind reply. Data structure doesn't have date. So this function cannot be used.
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
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: