hi,
iam struggling to create output to get the current year,current month,previous_year,previous_month.
and iam using below code and iam not getting waht iam expecting please.kindly help
expected output should be
all the columns should be in numeric format and not character format
proc sql;
create view work.WXVDZU as
select
(year(today())) as Current_Year length = 8
format = z2.
informat = z2.,
(month(today())) as Current_Month length = 8
format = z2.
informat = z2.,
(%sysfunc(year(%sysfunc(intnx(month, %sysfunc(today()), -1))))) as Previous_Year length = 8
format = z2.
informat = z2.,
(%sysfunc(month(%sysfunc(intnx(month, %sysfunc(today()), -1))))) as Previour_Month length = 8
format = z2.
informat = z2.
from &etls_lastTable
;
quit;;
To simply create a dataset, use SAS' in-built Swiss Army Knife, aka The Data Step:
data wxvdzu;
length
current_year
current_month
previous_year
previous_month
3
;
format
current_year
previous_year
z4.
current_month
previous_month
z2.
;
current_year = year(today());
current_month = month(today());
previous_year = year(intnx('month',today(),-1));
previous_month = month(intnx('month',today(),-1));
run;
Just to understand, all you want is a table with the current year, month, the previous year and the previous month?
yes @PeterClemmensen .all i need is with the current year, current month, the previous year and the previous month values with numeric columns.
also i need informat and format values also what to mention
as iam using this in SAS DI please
The view you are trying to create does not need any variable from "&etls_lastTable", right? Why do want to create a view at all?
You only need %SYSFUNC if you are doing calculations on macro variables, and I see no macro variables at all. You can start by removing all uses of %SYSFUNC.
To simply create a dataset, use SAS' in-built Swiss Army Knife, aka The Data Step:
data wxvdzu;
length
current_year
current_month
previous_year
previous_month
3
;
format
current_year
previous_year
z4.
current_month
previous_month
z2.
;
current_year = year(today());
current_month = month(today());
previous_year = year(intnx('month',today(),-1));
previous_month = month(intnx('month',today(),-1));
run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.