<?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: Counting the number of smallest and highest values in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809484#M33752</link>
    <description>&lt;P&gt;Thank you for the reply . I need to validate product_id variable using univariate procedure alone. The values which should be exactly 12 digits , to check how many values of product_id are too small or too large? So I am using this but getting sam e results&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 24 Apr 2022 12:33:32 GMT</pubDate>
    <dc:creator>archita</dc:creator>
    <dc:date>2022-04-24T12:33:32Z</dc:date>
    <item>
      <title>Counting the number of smallest and highest values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809439#M33744</link>
      <description>&lt;PRE&gt;proc univariate data=blib.shoes_tracker;
var product_id;
run;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="archita_0-1650714618193.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70757i52E4EBDD973838E8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="archita_0-1650714618193.png" alt="archita_0-1650714618193.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am trying to find out how many values are too small or too large for variable product_id. The values should be exactly 12 digits. I want to understand is the answer 3&amp;nbsp; for smallest values and 4 for largest values? Please help. I am bit confused.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2022 11:52:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809439#M33744</guid>
      <dc:creator>archita</dc:creator>
      <dc:date>2022-04-23T11:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of smallest and highest values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809441#M33745</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130051"&gt;@archita&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The results in the table indicate that four values have only 11 integer digits (decimals not counted!) and eight values have 13.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you store product IDs as &lt;EM&gt;character&lt;/EM&gt; variables, which is generally recommended, you will no longer be confused by scientific notation ("...E+10" etc.).&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2022 12:50:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809441#M33745</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-04-23T12:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of smallest and highest values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809442#M33746</link>
      <description>&lt;P&gt;By treating PRODUCT_ID as numeric, and then using PROC UNIVARIATE, it cannot display all of the digits of the PRODUCT_ID. Because you have PRODUCT_ID as numeric, then the values are displayed in scientific notation, which would normally be fine for numeric variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But PRODUCT_ID should not be numeric. It should be a character string. And then PROC FREQ can be used to answer your question, and no scientific notation will appear in the output. (Actually PROC FREQ will do what you want on numeric values, but honestly, you shouldn't be making PRODUCT_ID numeric, that's just a bad thing to do)&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2022 12:52:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809442#M33746</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-23T12:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of smallest and highest values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809481#M33750</link>
      <description>&lt;PRE&gt;data out;
set blib.shoes_tracker;
format product_id $12.;
run;
proc univariate data=out;
var product_id;
run;&lt;/PRE&gt;&lt;P&gt;Hi, thanks for replying , I modified the code but still not getting the results. Please let me know here I am wrong?&lt;/P&gt;</description>
      <pubDate>Sun, 24 Apr 2022 11:23:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809481#M33750</guid>
      <dc:creator>archita</dc:creator>
      <dc:date>2022-04-24T11:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of smallest and highest values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809483#M33751</link>
      <description>&lt;P&gt;Assigning a $12. format won't work if the variable is numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So why don't you try PROC FREQ?&lt;/P&gt;</description>
      <pubDate>Sun, 24 Apr 2022 12:26:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809483#M33751</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-24T12:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of smallest and highest values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809484#M33752</link>
      <description>&lt;P&gt;Thank you for the reply . I need to validate product_id variable using univariate procedure alone. The values which should be exactly 12 digits , to check how many values of product_id are too small or too large? So I am using this but getting sam e results&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Apr 2022 12:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809484#M33752</guid>
      <dc:creator>archita</dc:creator>
      <dc:date>2022-04-24T12:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of smallest and highest values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809486#M33753</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130051"&gt;@archita&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for the reply . I need to validate product_id variable using univariate procedure alone.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This doesn't make sense to require PROC UNIVARIATE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;The values which should be exactly 12 digits , to check how many values of product_id are too small or too large? &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As pointed out by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt; some of your data is 13 digits, and some is 11 digits. As pointed out by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt; and myself, forcing these values to be numeric makes your life difficult, they should be character variables, and then PROC FREQ gives the answer easily.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Apr 2022 12:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809486#M33753</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-24T12:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of smallest and highest values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809489#M33755</link>
      <description>&lt;P&gt;Thanks for the information. But the variable is numeric only.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Apr 2022 13:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809489#M33755</guid>
      <dc:creator>archita</dc:creator>
      <dc:date>2022-04-24T13:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of smallest and highest values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809490#M33756</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130051"&gt;@archita&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;data out;
set blib.shoes_tracker;
format product_id $12.;
run;
proc univariate data=out;
var product_id;
run;&lt;/PRE&gt;
&lt;P&gt;Hi, thanks for replying , I modified the code but still not getting the results. Please let me know here I am wrong?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since &lt;FONT face="courier new,courier"&gt;product_id&lt;/FONT&gt; must be a &lt;EM&gt;numeric&lt;/EM&gt; variable (otherwise the PROC UNIVARIATE step in your initial post would not have produced a result), SAS interprets your FORMAT statement as&lt;/P&gt;
&lt;PRE&gt;format product_id &lt;FONT color="#FF0000"&gt;12.&lt;/FONT&gt;;&lt;/PRE&gt;
&lt;P&gt;which doesn't impact the results from PROC UNIVARIATE. (A warning "&lt;FONT face="courier new,courier"&gt;Variable product_id has already been defined as numeric.&lt;/FONT&gt;" should have appeared in the log of the DATA step.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The type of an existing variable cannot change anyway. Even if you modified your input dataset&amp;nbsp;&lt;FONT face="courier new,courier"&gt;blib.shoes_tracker&lt;/FONT&gt; so that &lt;FONT face="courier new,courier"&gt;product_id&lt;/FONT&gt; is now a character variable, assigning the $12. format would be counterproductive: The longer values would be displayed &lt;EM&gt;truncated&lt;/EM&gt; to 12 characters (e.g., in PROC PRINT or PROC FREQ output), making it impossible to recognize their actual length (13).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Luckily, you &lt;EM&gt;did&lt;/EM&gt; get the desired results already from the table you've shown in your initial post: F&lt;SPAN&gt;our &lt;FONT face="courier new,courier"&gt;product_id&lt;/FONT&gt; values (displayed as 2.20200E+10) have only 11 integer digits, i.e., are "too short," and eight values (displayed as 2.2020E+12) have 13 digits, i.e., are "too long."&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Apr 2022 14:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809490#M33756</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-04-24T14:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of smallest and highest values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809497#M33758</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130051"&gt;@archita&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the information. But the variable is numeric only.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just because a variable is provided in an inappropriate way (it should be text), that does not mean you have to work with it as numeric, you can create a character variable and work with it that way. But anyway, as I said above, PROC FREQ will do what you want on numeric variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, with character variables, you can use the LENGTH function to determine if any observations have 11 or 13 characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if you insist on doing thing with a numeric variable, you can test to see if the number is less than the smallest 12 digit integer; or greater than the largest 12 digit integer.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Apr 2022 14:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809497#M33758</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-24T14:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the number of smallest and highest values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809515#M33761</link>
      <description>&lt;P&gt;Thank you so much , got your point.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Apr 2022 17:11:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-the-number-of-smallest-and-highest-values/m-p/809515#M33761</guid>
      <dc:creator>archita</dc:creator>
      <dc:date>2022-04-24T17:11:56Z</dc:date>
    </item>
  </channel>
</rss>

