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
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 21875 views
  • 0 likes
  • 3 in conversation