<?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: Interacting with cas results in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Interacting-with-cas-results/m-p/867749#M342727</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to the doc (&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/default/caslpg/p1xhd1xslkblfan16lcboym5nle9.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/default/caslpg/p1xhd1xslkblfan16lcboym5nle9.htm&lt;/A&gt;) for the result table compute operator, it is only possible to have one column added. To add a second column you do need a second statement, see example below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data casuser.cars;
set sashelp.cars;
if horsepower le 340;
run;

%let casy1=cars;
%let liby1=casuser;


proc cas;
    simple.distinct result=dist /
        table={name="&amp;amp;casy1.", caslib="&amp;amp;liby1."};
    run;
    table.recordCount result=count /
        table={name="&amp;amp;casy1.", caslib="&amp;amp;liby1."};
    run;
    nrows=findtable(count)[1,1];
    computedcolumn=findtable(dist).
      compute({"n_rows", "number of rows", best12.}, nrows);
    subset= computedcolumn; 
    saveresult subset dataout=work.&amp;amp;casy1.;
    print subset;
    run;
    computedColumn = computedColumn.compute(
      {"filter", "where clause", $4096.}, "make = 'Europe'"
      );
    print computedColumn;
    describe computedColumn;
run;
  saveresult computedColumn dataout=work.final ;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 03 Apr 2023 12:51:15 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2023-04-03T12:51:15Z</dc:date>
    <item>
      <title>Interacting with cas results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Interacting-with-cas-results/m-p/867733#M342725</link>
      <description>&lt;P&gt;My code works for 1 computed column, but I cannot manage to get a second column attached.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32"&gt;@BrunoMueller&lt;/a&gt;&amp;nbsp;, any idea?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code is based on&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;H1 id="p1ioxwkh6crvhrn1alvzokmxsuyr" class="xis-title"&gt;Example 7: Subsetting A Computed Column&lt;/H1&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/proccas/p1ioxwkh6crvhrn1alvzokmxsuyr.htm" target="_self"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/proccas/p1ioxwkh6crvhrn1alvzokmxsuyr.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data casuser.cars;
set sashelp.cars;
if horsepower le 340;
run;

%let casy1=cars;
%let liby1=casuser;


proc cas;

    simple.distinct result=dist /
        table={name="&amp;amp;casy1.", caslib="&amp;amp;liby1."};
    run;
    table.recordCount result=count /
        table={name="&amp;amp;casy1.", caslib="&amp;amp;liby1."};
    run;
    nrows=findtable(count)[1,1];
    computedcolumn=findtable(dist).
      compute({"n_rows", "number of rows", best12.}, nrows)
      [, {"Column", "ndistinct","nmiss", "n_rows"}];
    subset= computedcolumn; 

    saveresult subset dataout=work.&amp;amp;casy1.;
    run;

    simple.distinct result=dist /
        table={name="&amp;amp;casy1.", caslib="&amp;amp;liby1."};
    run;
    table.recordCount result=count /
        table={name="&amp;amp;casy1.", caslib="&amp;amp;liby1."};
    run;
    nrows=findtable(count)[1,1];
    computedcolumn=findtable(dist).
      compute({"filter", "filter criteria", $200.},  
                    "if horsepower le 340")
      [, {"Column", "ndistinct","nmiss", "filter"}];
    subset= computedcolumn; 

    saveresult subset dataout=work.filt_&amp;amp;casy1.;
    run;

    simple.distinct result=dist /
        table={name="&amp;amp;casy1.", caslib="&amp;amp;liby1."};
    run;
    table.recordCount result=count /
        table={name="&amp;amp;casy1.", caslib="&amp;amp;liby1."};
    run;
    nrows=findtable(count)[1,1];
    computedcolumn=findtable(dist).
      compute({{"n_rows", "number of rows", best12.}, nrows} ,
              {{"filter", "filter criteria", $200.},  
                    "if horsepower le 340" })
      [, {"Column", "ndistinct","nmiss", "n_rows", "filter"}];

    subset= computedcolumn; 

    saveresult subset dataout=work.&amp;amp;casy1._2cols;
    run;


run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2023 11:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Interacting-with-cas-results/m-p/867733#M342725</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2023-04-03T11:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Interacting with cas results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Interacting-with-cas-results/m-p/867749#M342727</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to the doc (&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/default/caslpg/p1xhd1xslkblfan16lcboym5nle9.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/default/caslpg/p1xhd1xslkblfan16lcboym5nle9.htm&lt;/A&gt;) for the result table compute operator, it is only possible to have one column added. To add a second column you do need a second statement, see example below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data casuser.cars;
set sashelp.cars;
if horsepower le 340;
run;

%let casy1=cars;
%let liby1=casuser;


proc cas;
    simple.distinct result=dist /
        table={name="&amp;amp;casy1.", caslib="&amp;amp;liby1."};
    run;
    table.recordCount result=count /
        table={name="&amp;amp;casy1.", caslib="&amp;amp;liby1."};
    run;
    nrows=findtable(count)[1,1];
    computedcolumn=findtable(dist).
      compute({"n_rows", "number of rows", best12.}, nrows);
    subset= computedcolumn; 
    saveresult subset dataout=work.&amp;amp;casy1.;
    print subset;
    run;
    computedColumn = computedColumn.compute(
      {"filter", "where clause", $4096.}, "make = 'Europe'"
      );
    print computedColumn;
    describe computedColumn;
run;
  saveresult computedColumn dataout=work.final ;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2023 12:51:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Interacting-with-cas-results/m-p/867749#M342727</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2023-04-03T12:51:15Z</dc:date>
    </item>
  </channel>
</rss>

