BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
navyaroopa
Calcite | Level 5

Hi,

 I have my program as

 

%let date=26Jan2017;

%let time=0012;

 

%let dattt= %sysfunc(catx(T,&date,&time));

 

%put &dattt;

 

the value for &dattt is 26Jan2017T12,

But i want my value as 26Jan2017T0012,

Why im not getting 0012 for my time.

Please could any one help.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Catx converts it to a number. Don't use it. 

 

 

%let datt=&date.T&time.;

 

View solution in original post

6 REPLIES 6
Reeza
Super User

Catx converts it to a number. Don't use it. 

 

 

%let datt=&date.T&time.;

 

navyaroopa
Calcite | Level 5

I have used  &date.T&time   as an alternative in the program, but wanted to know Why catx is not working. 

Reeza
Super User

It thinks it's a number. Because the function takes char and num types either are valid and it has to guess at types in macro format. I don't know what the rules are, if you're really interested I would contact tech support. 

 

You may be able to force it in the SYSFUNC by including quotes around the value. 

 

 

navyaroopa
Calcite | Level 5

Hi Reeza,

 

I have given with the quotes as %let datt=%sysfunc(catx(T,"&date","&time"));

 

I am getting the value but along with the quotes.

 

I would be very Thankfull if you could consult  tech support and help me to know this.

 

Thank You.

Reeza
Super User

Sorry, I meant to say you could contact tech support 🙂 

 

 

Quentin
Super User

Agree with @Reeza.  I don't see a way to tell CATX that the value that looks like a number is not a number.  And generally for concatenation in the macro language CAT functions are not needed, as shown in the accepted solution.

 

That said, if you went the route of adding quote marks, in the macro language those quote marks are part of the value (not a way to indicate that a value is text).  The good news is that when a quote mark (or any other non-numeric character) is part of the value, CATX will see that it is not a number.  But because those quote marks become part of the value, you would have to removed them yourself.

 

So in theory, you could hack it as something like:

40   %let date=26Jan2017;
41   %let time=0012;
42   %let datt=%sysfunc(compress(%sysfunc(catx(T,"&date","&time")),%str(%")));
43   %put &datt;
26Jan2017T0012
The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.

SAS Innovate 2025: Register Now

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!

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
  • 6 replies
  • 23351 views
  • 0 likes
  • 3 in conversation