Hello,
I have a macro I am working on that requires a template list of texts/prompts that can be used and then subsequently modified based on what is required. so basically the macro call would be
%macro(text=" ");
However, I want a drop down list that can be modified after text so something like
%macro( text="Do this <insert instruction>"
"Do that < insert instruction>"
"Describe this <insert object>");
I see there is custom tasks in SAS Studio or insert prompt and SAS EG but the issue I'm having is that you store the list in a macro and then add it to the macro. However I have to run it and then select the pre-populated values.
%macro(text=&list.);
Is there a way I can just bring up the template values that I can modify prior to running the macro or is that functionality not currently possible?
%macro test(parameter,insert_code)/minoperator;
%if %superq(PARAMETER) = %then
%do;
%put NOTE: This is a help info form macro &sysmacroname.;
%put NOTE- The PARAMETER parameter allows only the below;
%put NOTE- list of values for actions:;
%put NOTE- `explain` for: "I want you to act as a code explainer in SAS. I don't understand this function. Can you please explain what it does, and provide an example? {Insert Code}";
%put NOTE-;
%put NOTE- `optimize` for "I want you to act as a code optimizer in SAS. {Describe problem with current code, if possible}. Can you make the code {cleaner/more efficient/run faster/more readable}? {Insert Code}";
%goto EndOfMacro;
%end;
%if NOT (%superq(PARAMETER) in (explain optimize)) %then
%do;
%put ERROR: The PARAMETER parameter has bad value!;
%test()
%goto EndOfMacro;
%end;
%put THE CODE: %superq(insert_code);
%EndOfMacro:
%mend test;
%test()
%test(explain, (data test123; set sashelp.class; do i=1,2,3; put i; end; run;))
%test(blabla)
1) why you will need a drop down list if you are going to use it like that:
%macro(text=&list.);
?
2) maybe macro design with testing + minoperator can do the job:
%macro test(parameter)/minoperator;
%if %superq(PARAMETER) = %then
%do;
%put NOTE: This is a help info form macro &sysmacroname.;
%put NOTE- The PARAMETER parameter allows only the following;
%put NOTE- list of values:;
%put NOTE- Aaa;
%put NOTE- Bbb;
%put NOTE- Ccc;
%goto EndOfMacro;
%end;
%if NOT (%superq(PARAMETER) in (Aaa Bbb Ccc)) %then
%do;
%put ERROR: The PARAMETER parameter has bad value!;
%test()
%goto EndOfMacro;
%end;
data &PARAMETER;
set sashelp.class;
run;
%EndOfMacro:
%mend test;
?
Bart
@yabwon Okay full context I want to use it to create SAS specific template list of prompts for a ChatGPT Macro to use within SAS to get the most efficiency (or attempt to) so I wanted to create prompts such as this.
"I want you to act as a code explainer in SAS. I don't understand this function. Can you please explain what it does, and provide an example? {Insert Code}" so you could ask PROC FCMP or PROC HTTP
"I want you to act as a code optimizer in SAS. {Describe problem with current code, if possible}. Can you make the code {cleaner/more efficient/run faster/more readable}? {Insert Code}"
So a user can choose from a drop down list (albeit a partially modifiable drop down list) and then modify/tailor based on their particular issue/requirements
%macro test(parameter,insert_code)/minoperator;
%if %superq(PARAMETER) = %then
%do;
%put NOTE: This is a help info form macro &sysmacroname.;
%put NOTE- The PARAMETER parameter allows only the below;
%put NOTE- list of values for actions:;
%put NOTE- `explain` for: "I want you to act as a code explainer in SAS. I don't understand this function. Can you please explain what it does, and provide an example? {Insert Code}";
%put NOTE-;
%put NOTE- `optimize` for "I want you to act as a code optimizer in SAS. {Describe problem with current code, if possible}. Can you make the code {cleaner/more efficient/run faster/more readable}? {Insert Code}";
%goto EndOfMacro;
%end;
%if NOT (%superq(PARAMETER) in (explain optimize)) %then
%do;
%put ERROR: The PARAMETER parameter has bad value!;
%test()
%goto EndOfMacro;
%end;
%put THE CODE: %superq(insert_code);
%EndOfMacro:
%mend test;
%test()
%test(explain, (data test123; set sashelp.class; do i=1,2,3; put i; end; run;))
%test(blabla)
Appreciated as always @yabwon !
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.