Hello, I have a SQL-code with connection to Teradata. Incide this code SAS macro - %month_diff_td. How can I view (and change) the code?
I use %copy
%copy MONTHS_DIFF_TD() / SOURCE;
but it doesn't help:
14 GOPTIONS ACCESSIBLE; ERROR: This combination of default and specified %COPY statement options is not supported. ERROR: An error occurred during the execution of the %COPY statement. 15 %copy MONTHS_DIFF_TD() / SOURCE; _ 180 ERROR 180-322: Statement is not valid or it is used out of proper order.
May be I can use some fing tool using macro name?
Look at the source code which created the macro? If you don't have the source code and only have the compiled catalog then that should work, unless of course the catalog is set to protect the contents - one thing which I detest in programming. This is why I strongly advise against the use of catalogs in any sense as the whole 32/64bit debacle has proved.
Oh, and you don't specify ():
Should read:
%copy MONTHS_DIFF_TD/SOURCE;
Assuming months_diff_td is the correct name of the macro.
When I drop "()" I have error
ERROR: Macro MONTHS_DIFF_TD not found in libref MAMACRO.
ERROR: An error occurred during the execution of the %COPY statement.
Macro is exist! I found in by hands (running over all folders)
%macro MONTHS_DIFF_TD(date1,date2); cast(((&date2 - &date1) month(3)) as integer ) %mend;
%COPY doesn't search your folders, it only works if the macro is already compiled and stored somewhere in your SAS system already.
Ok, %Copy can't solve my problem. Maybe somebody know a way How to fing a macro in Explorer window
Well
- You can check your autoexec.sas (or other startup files) and see if there is an:
options sasautos=...;
Statement there - that is the first place SAS looks for them.
- Then your programs could include further ones or define them - so look at your startup files, and any other programs you run.
- Finally, there is the proc scaproc procedure, which does some code analyzing, you start it before your run, then after to get some results - however this might not capture everything if they are set in start programs.
i suppose the question at the end of the day is why you don't know where the macros are, I mean to be able to use macros you should know something about them. I know most don't bother, but properly developed code should have user guides, testing and such like that you should be aware of before using them, much like any software development.
You seem to misunderstand what the macro statement %copy does.
Look at the documentation here: %COPY Statement
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: