<?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 quoting issue inside call execute and proc cas statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/quoting-issue-inside-call-execute-and-proc-cas-statement/m-p/854511#M337710</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A data _null_ step shows that my approach works without the quoting issue:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
_statistic_="Average-Quantile";
_arg1_=.;
want=compress(cats(_statistic_, _arg1_),".-");
put want=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But when I use the compress function within the call execute construct, I cannot make it work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know how to pass the arguments "-." to the compress function. I seems like I have to quote the quote.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"'"&lt;/P&gt;
&lt;P&gt;"""""&lt;/P&gt;
&lt;P&gt;'||"'"&lt;/P&gt;
&lt;P&gt;???&lt;/P&gt;
&lt;P&gt;I'm aware that my code below cannot be reproduced without data and macro variables, ...&lt;/P&gt;
&lt;P&gt;But it works when I replace the error producing line (compress) with a hard-coded value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set xdata2;
call execute('
%let varlist="";
proc cas;
    action columninfo result=r /table={name="'|| strip(name) || '", caslib="ORACASLIB"};   
    empty = 0;
    if (r.columnInfo.nrows &amp;lt;= 0) then do;
      empty = 1;
      rc = symput("emptyTable", (string)empty);
    end;
    else do;
      columns = "";
        do i = 1 to r.columninfo.nrows;
      if ^index(UPCASE(r["columninfo"][i,4]), "CHAR") or 1=2 THEN do;
            symput("col", quote(r[1,i].column));
            columns = columns||", "||symget("col");
      end;
      end;
      symput("varlist", substrn(columns,2,length(columns)-1));
    end;
run;

quit;

proc cas;
dataPreprocess.rustats / 
table={name="'|| strip(name) || '", caslib="ORACASLIB"}, inputs={' || symget(varlist) || '},
requestpackages={{allLocations=TRUE, allSkewnesses=TRUE}},
casoutstats={name="mydata_rustats",caslib="casuser", replace=true};
run;

transpose.transpose /
table={caslib="casuser", name="mydata_rustats", groupby={"_variable_"}, 
computedvars={{name="newid",format="$20."}},

computedvarsprogram="newid=' || compress(cats(_statistic_, _arg1_),".-") ||';"},
transpose={"_value_"}, id={"newid"}, casOut={caslib="casuser", name="'|| catx("_", strip(name)) || '", 
replace=true};
run;
quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jan 2023 08:52:18 GMT</pubDate>
    <dc:creator>acordes</dc:creator>
    <dc:date>2023-01-19T08:52:18Z</dc:date>
    <item>
      <title>quoting issue inside call execute and proc cas statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quoting-issue-inside-call-execute-and-proc-cas-statement/m-p/854511#M337710</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A data _null_ step shows that my approach works without the quoting issue:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
_statistic_="Average-Quantile";
_arg1_=.;
want=compress(cats(_statistic_, _arg1_),".-");
put want=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But when I use the compress function within the call execute construct, I cannot make it work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know how to pass the arguments "-." to the compress function. I seems like I have to quote the quote.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"'"&lt;/P&gt;
&lt;P&gt;"""""&lt;/P&gt;
&lt;P&gt;'||"'"&lt;/P&gt;
&lt;P&gt;???&lt;/P&gt;
&lt;P&gt;I'm aware that my code below cannot be reproduced without data and macro variables, ...&lt;/P&gt;
&lt;P&gt;But it works when I replace the error producing line (compress) with a hard-coded value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set xdata2;
call execute('
%let varlist="";
proc cas;
    action columninfo result=r /table={name="'|| strip(name) || '", caslib="ORACASLIB"};   
    empty = 0;
    if (r.columnInfo.nrows &amp;lt;= 0) then do;
      empty = 1;
      rc = symput("emptyTable", (string)empty);
    end;
    else do;
      columns = "";
        do i = 1 to r.columninfo.nrows;
      if ^index(UPCASE(r["columninfo"][i,4]), "CHAR") or 1=2 THEN do;
            symput("col", quote(r[1,i].column));
            columns = columns||", "||symget("col");
      end;
      end;
      symput("varlist", substrn(columns,2,length(columns)-1));
    end;
run;

quit;

proc cas;
dataPreprocess.rustats / 
table={name="'|| strip(name) || '", caslib="ORACASLIB"}, inputs={' || symget(varlist) || '},
requestpackages={{allLocations=TRUE, allSkewnesses=TRUE}},
casoutstats={name="mydata_rustats",caslib="casuser", replace=true};
run;

transpose.transpose /
table={caslib="casuser", name="mydata_rustats", groupby={"_variable_"}, 
computedvars={{name="newid",format="$20."}},

computedvarsprogram="newid=' || compress(cats(_statistic_, _arg1_),".-") ||';"},
transpose={"_value_"}, id={"newid"}, casOut={caslib="casuser", name="'|| catx("_", strip(name)) || '", 
replace=true};
run;
quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 08:52:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quoting-issue-inside-call-execute-and-proc-cas-statement/m-p/854511#M337710</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2023-01-19T08:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: quoting issue inside call execute and proc cas statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quoting-issue-inside-call-execute-and-proc-cas-statement/m-p/854518#M337712</link>
      <description>&lt;P&gt;CALL EXECUTE executes some macro code immediately. This may be the problem. There is also an error in your code, which is this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;symput("varlist", substrn(columns,2,length(columns)-1));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It is CALL SYMPUT, not just SYMPUT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There may also be some problems with nested quotes in your code, I am not sure. I generally do not use CALL EXECUTE for such solutions, I think it works better to generate a SAS program and %INCLUDE that. That way, you can first look at the code, to see if it looks all right, then try and submit it. If it works OK, you can put the %INCLUDE (may want to use the /SOURCE2 option) in your original code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename tempsas temp; /* temporary file, gets deleted when freed or reallocated */
data _null_;
set xdata2;
file tempsas;
put 
'%let varlist="";'/
'proc cas;'/
'    action columninfo result=r /table={' name= ', caslib="ORACASLIB"};'/   
'    empty = 0;' /
/* etcetera */
'quit;';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You will then have a file containing all the code generated. Open it, and see if it looks OK. If it does, try submitting the code down to the first "quit;" statement, and see if it generates the result you want. Then try submitting the rest of the file, and see if that also works.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 10:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quoting-issue-inside-call-execute-and-proc-cas-statement/m-p/854518#M337712</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2023-01-19T10:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: quoting issue inside call execute and proc cas statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quoting-issue-inside-call-execute-and-proc-cas-statement/m-p/854615#M337766</link>
      <description>&lt;P&gt;I can use it. But I don't know how to inspect / see the temp file...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include tempsas / source2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jan 2023 15:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quoting-issue-inside-call-execute-and-proc-cas-statement/m-p/854615#M337766</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2023-01-19T15:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: quoting issue inside call execute and proc cas statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quoting-issue-inside-call-execute-and-proc-cas-statement/m-p/854618#M337768</link>
      <description>&lt;P&gt;if you have temporary file use:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;filename tempsas list;&lt;/LI-CODE&gt;
&lt;P&gt;to see its location in the log;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 15:54:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quoting-issue-inside-call-execute-and-proc-cas-statement/m-p/854618#M337768</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-01-19T15:54:41Z</dc:date>
    </item>
  </channel>
</rss>

