BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
current_thing
Obsidian | Level 7

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.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

@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.

View solution in original post

10 REPLIES 10
PaigeMiller
Diamond | Level 26

@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?

--
Paige Miller
current_thing
Obsidian | Level 7

Hello,

 

I'm trying to put dt1 in a macro variable in date9. format.

Tom
Super User Tom
Super User

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?

 

current_thing
Obsidian | Level 7

Yes, but the problem is SAS log simply reprints the %put statement, instead of putting the &dt1 in date9. format.

Tom
Super User Tom
Super User

@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.);

 

current_thing
Obsidian | Level 7

I tried it, and I get 'quoted string currently being processed has become more than 262 characters long' in SAS log

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
Tom
Super User Tom
Super User

@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
Obsidian | Level 7

restart SAS worked! Thank you Tom

PaigeMiller
Diamond | Level 26
%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.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 2251 views
  • 1 like
  • 3 in conversation