I am attempting to use the month() function to extract the month from a date variable formatted as MONYY7 read from an xlsx file. It is returning the following error:
Ok, that's not how you create a new variable.
If you want to calculate a month you need to create a new variable within a data step.
See a tutorial here or the code below:
data calculate_month; *create a new data set called calculate_month;
set one; *data set imported in previous step;
month_num = month(date); *calculate month;
run;
Where's the rest of the code?
Post the log and error as well please.
@nelsondn wrote:
I am attempting to use the month() function to extract the month from a date variable formatted as MONYY7 read from an xlsx file. It is returning the following error:
num_mon = month(date);_______180ERROR 180-322: Statement is not valid or it is used out of proper order.
The code:
options ls=78 formdlim='*';
ods listing;
proc import OUT= work.one
DATAFILE= "/home/nelsondn0/sasuser.v94/Gasoline.xlsx" DBMS=XLSX REPLACE; GETNAMES=YES;
run;
num_mon = month(date);
Ok, that's not how you create a new variable.
If you want to calculate a month you need to create a new variable within a data step.
See a tutorial here or the code below:
data calculate_month; *create a new data set called calculate_month;
set one; *data set imported in previous step;
month_num = month(date); *calculate month;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.