I have the following code:
%let dt1=%sysfunc(mdy(1,24,2025)); %put %sysfunc(putn(&dt1,date9.));
%put simply reprints, instead of putting the date. What am I doing wrong? Thanks.
@current_thing wrote:
I tried it, and I get 'quoted string currently being processed has become more than 262 characters long' in SAS log
That is because you have unbalanced quotes in some code that you have submitted. There are things you can try to submit to balance the quotes. But I usually find it faster to just restart the SAS session and try again.
@current_thing wrote:
I have the following code:
%let dt1=%sysfunc(mdy(1,24,2025)); %put %sysfunc(putn(&dt1,date9.));%put simply reprints, instead of putting the date. What am I doing wrong? Thanks.
I don't understand what you are trying to do. What result do you want? What does "putting the date" mean? What will you do with this macro variable once it is created?
Hello,
I'm trying to put dt1 in a macro variable in date9. format.
Your first statement sets a macro variable to a particular date value.
Your second statement writes the date value in the macro to the SAS log using the PUTN() function to formatted it using the DATE9. format so that a human might recognize what date it is.
What are you trying to do?
Yes, but the problem is SAS log simply reprints the %put statement, instead of putting the &dt1 in date9. format.
@current_thing wrote:
Yes, but the problem is SAS log simply reprints the %put statement, instead of putting the &dt1 in date9. format.
You are using the same verb to mean many different things which is making you request very hard to understand.
I suspect that what you want is for the macro variable named DT1 to have the string produced by the DATE9. format when passed the date 24JAN2025.
You could ask %SYSFUNC() to do that for you.
%let dt1=%sysfunc(mdy(1,24,2025),date9.);
I tried it, and I get 'quoted string currently being processed has become more than 262 characters long' in SAS log
@current_thing wrote:
I tried it, and I get 'quoted string currently being processed has become more than 262 characters long' in SAS log
which means that somewhere earlier in your program, you have an unclosed quote
and you might be better off shutting down SAS, restarting it, and the problem should go away.
@current_thing wrote:
I tried it, and I get 'quoted string currently being processed has become more than 262 characters long' in SAS log
That is because you have unbalanced quotes in some code that you have submitted. There are things you can try to submit to balance the quotes. But I usually find it faster to just restart the SAS session and try again.
restart SAS worked! Thank you Tom
%let dt1=%sysfunc(mdy(1,24,2025));
%let dt1=%sysfunc(putn(&dt1,date9.));
Which brings me back to my earlier question ... what are you going to do with this macro variable once you have created it properly? There are times when having a macro variable with a value of 24JAN2025 isn't useful.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.