source code for macros

Accepted Solution Solved
Reply
Contributor
Posts: 44
Accepted Solution

source code for macros

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.


Accepted Solutions
Solution
‎10-07-2014 01:37 AM
Super User
Posts: 5,257

Re: source code for macros

  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


All Replies
Solution
‎10-07-2014 01:37 AM
Super User
Posts: 5,257

Re: source code for macros

  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
Contributor
Posts: 44

Re: source code for macros

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.

Super User
Super User
Posts: 6,500

Re: source code for macros

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).

Contributor
Posts: 44

Re: source code for macros

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.

Contributor
Posts: 44

Re: source code for macros

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;

Super User
Super User
Posts: 6,500

Re: source code for macros

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).

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 272 views
  • 6 likes
  • 3 in conversation