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.
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.
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).
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.
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;
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).
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.