BookmarkSubscribeRSS Feed
thryce85
Fluorite | Level 6

Playing around trying to learn FCMP.  Below is an example I can't figure out.  The hardcoded code and the function code are the same but the hardcoded actually works and function code will simple go the 0 date value?  I think it has sth to do the the input to arguement 1 but  its declared as text like it should be??  Appreciate your time and have a good one.

 

 

proc fcmp outlib= sasuser.funcs.clinical_project;


function make8601v1( in1 $ , in2 ) $;
temp = cat( put( in1 , IS8601DA.), "T" , put( in2 , TOD8. ) ) ;

return( temp);
endsub;
run;


data f1;
A='11/22/2018';
B='10:14:00't;
correct = cat( put( A , IS8601DA.), "T" , put( B , TOD8. ) ) ;
from_func = make8601v1(A,B);
run;

1 REPLY 1
ballardw
Super User

I question your claim that the "hard code" works. When I run your code without the FCMP procedure involved:

1    data f1;
2    A='11/22/2018';
3    B='10:14:00't;
4    correct = cat( put( A , IS8601DA.), "T" , put( B , TOD8. ) ) ;
                             ---------
                             484
NOTE 484-185: Format $IS8601DA was not found or could not be loaded.

5    run;

For A to be a date value that could use the IS8601DA format A would have to be: A="22Nov2018"D; The above generates an error because A is a character variable

If you want to combine a DATE value with a TIME value I would suggest using the DHMS function:

(assumes A is an actual date)

Correct = dhms(a,0,0,b);

And then assign an appropriate Format like E8601DT

 

Or if you really need a character value then: Correct = put(dhms(a,0,0,b),E8601dt19.);

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1 reply
  • 579 views
  • 2 likes
  • 2 in conversation