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

Hello all,

 

I am trying to retrieve code from a SAS catalog. I can view that there are 2 files of macro datatype in the sas catalog  I have used below code

data _null_;
infile macro;
input;
list;
run;

to retrieve a macro file. In the log I can see something like below, is there a way to view the actual SAS code? Please advise, any help is appreciated, Thanks!Capture.PNG

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If the macro wasn't defined with the Source and Store options were used when the macro was compiled you are going to have lots of fun.

 

You might try to see if the options were used:

%copy <macro>/ library=< the library the macro is in> source;

 

Macro would NOT include the % and the LIbrary should be other than the default work if used.

If it works the default behavior will be to write the code of the macro to the log.

 

If it doesn't you might hope you can find the code that created the macro.

 

View solution in original post

4 REPLIES 4
Reeza
Super User

Try %COPY.

 

%copy macro_name / SOURCE;

However, if the macro has not been compiled with the SOURCE option I'm not sure you'll get anything useful.

If the macro was compiled with the SECURE option you WILL NOT be able to reverse engineer the code. 

 

Any chance you can find the code used to build the macros?

 


@sredd wrote:

Hello all,

 

I am trying to retrieve code from a SAS catalog. I can view that there are 2 files of macro datatype in the sas catalog  I have used below code

data _null_;
infile macro;
input;
list;
run;

to retrieve a macro file. In the log I can see something like below, is there a way to view the actual SAS code? Please advise, any help is appreciated, Thanks!Capture.PNG

 

 


 

ballardw
Super User

If the macro wasn't defined with the Source and Store options were used when the macro was compiled you are going to have lots of fun.

 

You might try to see if the options were used:

%copy <macro>/ library=< the library the macro is in> source;

 

Macro would NOT include the % and the LIbrary should be other than the default work if used.

If it works the default behavior will be to write the code of the macro to the log.

 

If it doesn't you might hope you can find the code that created the macro.

 

sredd
Calcite | Level 5

Thank you! The Macro files are without % and are not saved by default in Work folder. So as you said this may not be defined with Source and Store options might have been used.

 

When I try to run below code

options sasmstore=lib.catalog;
%copy macro / source;

- it throws below errors, I am assuming it's because of the reason you specified. 

 'ERROR: Invalid logical name'

 'ERROR: An error occured during the execution of %COPY statement'

ballardw
Super User

@sredd wrote:

Thank you! The Macro files are without % and are not saved by default in Work folder. So as you said this may not be defined with Source and Store options might have been used.

 

When I try to run below code

options sasmstore=lib.catalog;
%copy macro / source;

- it throws below errors, I am assuming it's because of the reason you specified. 

 'ERROR: Invalid logical name'

 'ERROR: An error occured during the execution of %COPY statement'


It may be that you requested the name of a macro that did not exist. Or possibly it is with the SASMSTORE option.

With errors it is best to post the code and the error message from the log into a forum code box. Sometimes the error message format will indicate where the error was detected but with the code the message is incomplete.

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