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

Hi,

1.  Is there any way to get macro source code from the catalog?

session compiled macros:              if we miss source code after creation of macro by mistake,how can we update the macro?

stored compiled macros:                if we did not keep source option, then how to get the code for stored compiled macro?

Autocompiled macros:                    we have to keep source code.(no problem at all)

note:   From format catalogs, we can do cntlout option to get the dataset from format and we can update the format and submit again.

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20
  1. How do you mean? Do have an active session, created a macro, then lose the source code, and...? If you are in a DMS SAS session just do "recall".
  2. No, not with standard methods. This is a way to hide business logic, and a method for keeping things secret, like if you wish to sell a SAS based product.
  3. ? Good I guess..
Data never sleeps

View solution in original post

6 REPLIES 6
LinusH
Tourmaline | Level 20
  1. How do you mean? Do have an active session, created a macro, then lose the source code, and...? If you are in a DMS SAS session just do "recall".
  2. No, not with standard methods. This is a way to hide business logic, and a method for keeping things secret, like if you wish to sell a SAS based product.
  3. ? Good I guess..
Data never sleeps
rajeshm
Quartz | Level 8

hi,

I am using PC  sas.

1. I submitted a macro and mistakenly closed my enhanced editor. then i got this question how to retrive macro code.(session compiled macros)

2 . Assumed there is no straight forward way to get the source of macro from catalog(stored compiled macros)

3. Not a question because we are keeping source code (we have to keep source code anyway)

if my assumption is wrong let me know and thanks for the reply.

Tom
Super User Tom
Super User

You can easily open a new copy of the enhanced editor.

The RECALL command will work in any editor window ("enhanced" or standard program editor).

rajeshm
Quartz | Level 8

thanks a lot.

No one give me this answer.

till now i assumed that recall is for program editor only.  I am able to getting my code with recall in new editor.

rajeshm
Quartz | Level 8

hi tom,


Question 1: can we use macro functions in datastep (%scan,%sysfunc  etc)


Question 2: need output datasets for list of values in a varible in a dataset. could you please  correct the program.

*1. selecting all varible values from a varible in a table;

proc sql;

select distinct make into : makes separated by ' ' from sashelp.cars order by make;

quit;

*2.due to variable value  mercedes-benz compressing and printing the values;

%let makes=%sysfunc(compress(&makes,'-'));

%put &makes;

*3.  sorting the dataset to get the different values of varibles one by one(group processing);

proc sort data=sashelp.cars out=cars;

by make;

run;

*4. want to get each distinct value from varible and making  output to corresponding dataset.

data &makes;

set cars;

by make;

retain i 1;

if first.make  then

  do;

                output scan("&makes",i,' ');

  i+1;

  end;

run;

Tom
Super User Tom
Super User

You cannot dynamically generate the name of the output dataset during data step execution. You need to use macro code to generate separate OUTPUT statement for each table and then dynamically decide which output statement to execute.

So either you generate code like

data Acura Audi .... ;

set sashelp.cars ;

do select (make);

  when('Acura') output acura;

  when('Audi') output audi;

....

end;

run;

Or you could use one of the HASH object solutions. With those you can output a hash object to a table name that is generated dynamically (that is the vlaue of a run time variable).

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
  • 820 views
  • 6 likes
  • 3 in conversation