- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
%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)
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
%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)
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Appreciated as always @yabwon !