<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can I use SCAPROC to list macro arguments? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-SCAPROC-to-list-macro-arguments/m-p/910908#M359199</link>
    <description>&lt;P&gt;From a look at the docs, I don't think you can get the macro arguments.&amp;nbsp; The only feature I see relating to macro variables is you can get a record stating that a macro variable was created (SET) or referenced (GET).&amp;nbsp; So when I run:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc scaproc; 
   record 'Q:\junk\record.txt'; 
run;

%let q=1 ;

%macro foo(qqq=) ;
  %put &amp;amp;=qqq ;
%mend foo ;

%foo(qqq=0)

proc scaproc; 
   write; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I do get SYMBOL records for the creation of Q and QQQ, and the reference of QQQ:&lt;/P&gt;
&lt;PRE&gt;/* JOBSPLIT: SYMBOL SET Q */
/* JOBSPLIT: SYMBOL SET QQQ */
/* JOBSPLIT: SYMBOL GET QQQ */
&lt;/PRE&gt;
&lt;P&gt;But that isn't giving you the value assigned to a macro variable, or the name of the macro invoked.&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jan 2024 19:21:45 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2024-01-08T19:21:45Z</dc:date>
    <item>
      <title>Can I use SCAPROC to list macro arguments?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-SCAPROC-to-list-macro-arguments/m-p/909918#M358860</link>
      <description>&lt;P&gt;I have used SCAPROC to list particular variables in my code, but I can't seem to figure out a way to also list my macro arguments from the same code. An example of these arguments would be the report= and subject= in&lt;U&gt; EXAMPLE 1&lt;/U&gt;. I can use the code from &lt;U&gt;EXAMPLE 2&lt;/U&gt; to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;determine the table names used in the code and save it as a text file but I can't seem to be able to list the macro variables from &lt;U&gt;EXAMPLE 1&lt;/U&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone point me in a potential direction?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;EXAMPLE 1
%macro email_result;
	%if &amp;amp;syserr=0 or &amp;amp;syserr=4 %then %do;
		%dw_std_email(report="AUTO &amp;amp;report_name",subject="&amp;amp;subject_line",
		attach1="&amp;amp;file_path &amp;amp;file_name"
				content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
	%end;
%mend;
%email_result;


EXAMPLE 2
%macro document_table2;

%if &amp;amp;documentation_flag. = 'YES' %then %do;

proc scaproc;
write;
run;

filename sca_rec "&amp;amp;documentation.\&amp;amp;documentation_name..txt";

data myinfo;

infile sca_rec truncover;
input @1 scaline $256.;
length library_name $20 table_name $25 data_type $5;
keep library_name table_name data_type;
retain prxfile prxidata;

if _n_ = 1 then do;
	prxifile = prxparse("!\bJOBSPLIT: FILE INPUT SEQ (\b.*\b) \*/!");
	prxidata = prxparse("!\bJOBSPLIT: DATASET INPUT (\b.*\b) \*/!");
end;

	if prxmatch (prxidata,scaline) &amp;gt; 0 then do;
		if scan(prxposn(prxidata,1,scaline), -1) = 'MULTI' OR
			scan(prxposn(prxidata,1,scaline), -1) = 'SEQ' then do;
			myinfo = scan(prxposn(prxidata,1,scaline), -1, ' ');
				library_name = scan(myinfo,1, '.');
				table_name = scan(myinfo,2, '.');
				data_type = scan(myinfo,3, '.');
	end;
	else do;
			myinfo = scan(prxposn(prxidata,1,scaline), -1, ' ');
			library_name = scan(myinfo,1, '.');
			table_name = scan(myinfo,2, '.');
			data_type = scan(myinfo,3, '.');
		end;
	end;

		if library_name ne ' ';
run;


proc export data = myinfo
	outfile = "&amp;amp;documentation.\&amp;amp;documentation_name..xls"
	dbms = xls replace;
run;

%end;
%mend;
%document_table2;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2023 23:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-SCAPROC-to-list-macro-arguments/m-p/909918#M358860</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2023-12-29T23:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use SCAPROC to list macro arguments?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-SCAPROC-to-list-macro-arguments/m-p/909927#M358863</link>
      <description>&lt;P&gt;Not exactly answering your question but... One way to capture the SAS code macros generate is using &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p0j3zpinabl49ln13q5f5r1t46mg.htm" target="_self"&gt;option mfile&lt;/A&gt; which lets you route mprint output to an external file.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2023 03:11:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-SCAPROC-to-list-macro-arguments/m-p/909927#M358863</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-12-30T03:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use SCAPROC to list macro arguments?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-SCAPROC-to-list-macro-arguments/m-p/909934#M358869</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the answer from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;is exactly what you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should you still want to use PROC SCAPROC, then why don't you have a RECORD statement?&lt;BR /&gt;I only see&amp;nbsp;PROC SCAPROC with a WRITE statement.&lt;/P&gt;
&lt;P&gt;You need (I think!) to&amp;nbsp;&lt;SPAN&gt;specify a record file (like&amp;nbsp;&lt;/SPAN&gt;&lt;CODE class="xisDoc-variableValue"&gt;'record.txt'&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;) and write information from the &lt;STRONG&gt;SAS Code Analyzer&lt;/STRONG&gt;&amp;nbsp;(SCA) to that file.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Like here:&lt;BR /&gt;SAS® 9.4 and SAS® Viya® 3.5 Programming Documentation&lt;BR /&gt;Base SAS Procedures Guide&lt;BR /&gt;SCAPROC Procedure&lt;BR /&gt;Example 1: &lt;STRONG&gt;Specifying a Record File&lt;/STRONG&gt;&lt;BR /&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n189k80mdf3lbkn10rhifnic7zx8.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n189k80mdf3lbkn10rhifnic7zx8.htm&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Not sure if the written file will contain what you want though (I have never used PROC SCAPROC myself &lt;span class="lia-unicode-emoji" title=":slightly_frowning_face:"&gt;🙁&lt;/span&gt;).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;BR, Koen&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2023 10:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-SCAPROC-to-list-macro-arguments/m-p/909934#M358869</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-12-30T10:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use SCAPROC to list macro arguments?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-SCAPROC-to-list-macro-arguments/m-p/910895#M359197</link>
      <description>&lt;P&gt;Good morning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, I do have the record file. I just didn't post it as I supposed it was not relevant to the question. Thanks for taking the time to reply and offering help.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 16:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-SCAPROC-to-list-macro-arguments/m-p/910895#M359197</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2024-01-08T16:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use SCAPROC to list macro arguments?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-SCAPROC-to-list-macro-arguments/m-p/910908#M359199</link>
      <description>&lt;P&gt;From a look at the docs, I don't think you can get the macro arguments.&amp;nbsp; The only feature I see relating to macro variables is you can get a record stating that a macro variable was created (SET) or referenced (GET).&amp;nbsp; So when I run:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc scaproc; 
   record 'Q:\junk\record.txt'; 
run;

%let q=1 ;

%macro foo(qqq=) ;
  %put &amp;amp;=qqq ;
%mend foo ;

%foo(qqq=0)

proc scaproc; 
   write; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I do get SYMBOL records for the creation of Q and QQQ, and the reference of QQQ:&lt;/P&gt;
&lt;PRE&gt;/* JOBSPLIT: SYMBOL SET Q */
/* JOBSPLIT: SYMBOL SET QQQ */
/* JOBSPLIT: SYMBOL GET QQQ */
&lt;/PRE&gt;
&lt;P&gt;But that isn't giving you the value assigned to a macro variable, or the name of the macro invoked.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 19:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-SCAPROC-to-list-macro-arguments/m-p/910908#M359199</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-01-08T19:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use SCAPROC to list macro arguments?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-use-SCAPROC-to-list-macro-arguments/m-p/910910#M359200</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3264"&gt;@Jeff_DOC&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Typically when starting PROC SCAPROC, you would specify the recording file along with some options&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Start recording info to a text file ;
proc scaproc ;
   record "&amp;lt;FileName&amp;gt;" attr opentimes expandmacros ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In order to capture your macro programs logic and parameters, ensure to have at least the following options in effect before starting the recording&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen mprint mprintnest msglevel=i ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All the macro debugging information should be captured in the source code section with the recording output file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Ahmed&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 19:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-use-SCAPROC-to-list-macro-arguments/m-p/910910#M359200</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2024-01-08T19:53:12Z</dc:date>
    </item>
  </channel>
</rss>

