BookmarkSubscribeRSS Feed
IvchenkoMariya
Calcite | Level 5

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?

 

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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 ():

http://support.sas.com/documentation/cdl/en/mcrolref/67912/HTML/default/viewer.htm#p0oltlodtnemugn10...

 

Should read:

%copy MONTHS_DIFF_TD/SOURCE;

Assuming months_diff_td is the correct name of the macro. 

IvchenkoMariya
Calcite | Level 5

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;
Reeza
Super User

%COPY doesn't search your folders, it only works if the macro is already compiled and stored somewhere in your SAS system already. 

IvchenkoMariya
Calcite | Level 5
Ok, Copy
IvchenkoMariya
Calcite | Level 5

Ok, %Copy can't solve my problem. Maybe somebody know a way How to fing a macro in Explorer window

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

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
  • 7 replies
  • 1213 views
  • 2 likes
  • 4 in conversation