Hi,
I am using SA Enterprise Guide and I have a user choice date in parameter which I called "dated", and is from this type: "06/01/2017".
I created three macro variable following this:
%let dated_year = %sysfunc(year("&dated."d));
%let dated_month = %sysfunc(month("&dated."d));
%let dated_ym = %sysfunc(cats(&dated_year, &dated_month));
First question:
when i put dated_year is correct: "2017".
But when I put dated_month, it's written "1" instead of "01"...it's not very important for dated_month but more problematic for dated_ym which is "20171" instead of "201701".
Do you know how I should do?
Second question:
I want to format these three macro variable in character, but I don't know how to do it. Do you have an idea?
Thanks
1, You can use formats to zero-fill your numbers, like this
%let dated_month = %sysfunc(putn(%sysfunc(month("&dated."d)), z2.));
2. Macro variables are always character strings, so you shouldn't have any problem. Can you describe what you're trying to do in a little more detail?
Tom
1, You can use formats to zero-fill your numbers, like this
%let dated_month = %sysfunc(putn(%sysfunc(month("&dated."d)), z2.));
2. Macro variables are always character strings, so you shouldn't have any problem. Can you describe what you're trying to do in a little more detail?
Tom
Also note, once you have implemented Tom's solution, the last statement can be simplified:
%let dated_ym = &dated_year.&dated_month.;
Thanks for both of you.
I can accept only one topic as a solution, but you both helped me... for the first question.
For the second:
I try to do something like that:
PROC SQL;
CREATE TABLE A
(DA_IN char(6));
INSERT INTO A values (&dated_ym.);
QUIT;
RUN;
And I got this.
Value 1 of VALUES clause 1 does not match the data type of the corresponding column in the object-item list (in the SELECT
clause).
Oups sorry I know, I just forgot the double-quotes :S
Sorry for this.
If it's not a semicolon I'm missing, it's a double quote!!
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.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.