<?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: Distinct count  where the variable matches SAS macro name in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Distinct-count-where-the-variable-matches-SAS-macro-name/m-p/903995#M83136</link>
    <description>&lt;P&gt;Your posted program works fine for me. There are no warnings or errors. Please post your full SAS log if you are getting a different result.&lt;/P&gt;</description>
    <pubDate>Mon, 20 Nov 2023 19:06:46 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2023-11-20T19:06:46Z</dc:date>
    <item>
      <title>Distinct count  where the variable matches SAS macro name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Distinct-count-where-the-variable-matches-SAS-macro-name/m-p/903969#M83135</link>
      <description>&lt;DIV&gt;Hello everyone, I have a table where the column/variable matches one of SAS' macro, how can I suppress this or is there an alternative?&amp;nbsp; Thank you all!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Data have (rename=(make=user));&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;set sashelp.cars;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;options validvarname=any;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc sql;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Create table Dist_Val_COL_USER as&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;select&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"user" as Column_Name,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;count(distinct user) as Num_Dist_Values format comma10.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from work.have&lt;/SPAN&gt;&lt;SPAN&gt; ;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;quit;&lt;/DIV&gt;</description>
      <pubDate>Mon, 20 Nov 2023 16:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Distinct-count-where-the-variable-matches-SAS-macro-name/m-p/903969#M83135</guid>
      <dc:creator>ljim1075</dc:creator>
      <dc:date>2023-11-20T16:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct count  where the variable matches SAS macro name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Distinct-count-where-the-variable-matches-SAS-macro-name/m-p/903995#M83136</link>
      <description>&lt;P&gt;Your posted program works fine for me. There are no warnings or errors. Please post your full SAS log if you are getting a different result.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 19:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Distinct-count-where-the-variable-matches-SAS-macro-name/m-p/903995#M83136</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-11-20T19:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct count  where the variable matches SAS macro name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Distinct-count-where-the-variable-matches-SAS-macro-name/m-p/903997#M83137</link>
      <description>There's no error but the count = 1 which is the count of 'you' the user, where the true count should be 38, True query:&lt;BR /&gt;Data have;&lt;BR /&gt;set sashelp.cars (keep=make);&lt;BR /&gt;run;&lt;BR /&gt;proc sql;&lt;BR /&gt;Create table Dist_Val_COL_USER as&lt;BR /&gt;select&lt;BR /&gt;"user" as Column_Name,&lt;BR /&gt;count(distinct make) as Num_Dist_Values format comma10.&lt;BR /&gt;from work.have&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Nov 2023 19:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Distinct-count-where-the-variable-matches-SAS-macro-name/m-p/903997#M83137</guid>
      <dc:creator>ljim1075</dc:creator>
      <dc:date>2023-11-20T19:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct count  where the variable matches SAS macro name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Distinct-count-where-the-variable-matches-SAS-macro-name/m-p/903998#M83138</link>
      <description>&lt;P&gt;The keyword USER has special meaning in PROC SQL.&lt;/P&gt;
&lt;P&gt;You need to type something slightly different so it knows you want the variable and not the ID of the current USER.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Easiest is to add the table alias:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;count(distinct have.user) &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you could also try using a name literal:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;count(distinct 'user'n) &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 19:30:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Distinct-count-where-the-variable-matches-SAS-macro-name/m-p/903998#M83138</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-20T19:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct count  where the variable matches SAS macro name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Distinct-count-where-the-variable-matches-SAS-macro-name/m-p/904003#M83139</link>
      <description>That worked!, TY!</description>
      <pubDate>Mon, 20 Nov 2023 20:14:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Distinct-count-where-the-variable-matches-SAS-macro-name/m-p/904003#M83139</guid>
      <dc:creator>ljim1075</dc:creator>
      <dc:date>2023-11-20T20:14:53Z</dc:date>
    </item>
  </channel>
</rss>

