<?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: Basic Question in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question/m-p/121220#M33429</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot, your post were greatly helpful and made my code work !!&lt;/P&gt;&lt;P&gt;I am also very impressed by the speed of your replies !!&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Nov 2012 15:57:02 GMT</pubDate>
    <dc:creator>fredkho</dc:creator>
    <dc:date>2012-11-08T15:57:02Z</dc:date>
    <item>
      <title>Basic Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question/m-p/121215#M33424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new to SAS.&lt;/P&gt;&lt;P&gt;I have a file price_sas located in a library called F which contains multiple columns.&lt;/P&gt;&lt;P&gt;I have columns named A, B, C, D, E which contain prices of items as information.&lt;/P&gt;&lt;P&gt;For columns A, I would like to find how many items cost between 0 and 1 dollar, how many items cost between 1 and 4 dollars, how many items cost between 4 and 8 and above 8.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to repeat this procedure for the other columns using different bounds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having trouble making it work and spent hours on it already, being new to SAS I would greatly appreciate your help and support.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fred&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question/m-p/121215#M33424</guid>
      <dc:creator>fredkho</dc:creator>
      <dc:date>2012-11-08T15:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question/m-p/121216#M33425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course you can do it using data step, while Proc SQL will be more straighforward IMHO:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*take variable A as example: NOT tested*/&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select sum(0&amp;lt;A&amp;lt;=1) as A01, sum(1&amp;lt;A&amp;lt;=4) as A14, sum(4&amp;lt;A&amp;lt;=8) as A48, sum(A&amp;gt;8) as A8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from F.price_sas&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:29:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question/m-p/121216#M33425</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-11-08T15:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question/m-p/121217#M33426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; Since you did not show your code, it's hard to comment on what else you should try. But, if you look at SASHELP.CLASS, you will see that there are 19 students with ages from 11-16. I can use PROC FREQ to show those students in grouped in my categories, where ages 11-12 are categorized as 'children', ages 13-15 are categorized as 'non-drivers' and ages 16-and up are categorized as 'teenage drivers'. PROC FORMAT allows me to create the categories and then I just use a simple PROC FREQ to get the frequency counts and percents, as shown in the attached screen shot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc format;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; value status 11-12='children'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 13-15='non-driver'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16-high='teenage drivers';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods html file='c:\temp\status.html';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; title 'Use FORMAT for Categories';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; proc freq data=sashelp.class;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tables age ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; format age status.;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods html close;&lt;/STRONG&gt;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/11114i00C549B66817B0C6/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="use_format.png" title="use_format.png" /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question/m-p/121217#M33426</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2012-11-08T15:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question/m-p/121218#M33427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A format applied to your data with a proc freq should give you what you want. Or you can go through and recode your data and then run a proc freq.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format&lt;/P&gt;&lt;P&gt;value a_fmt&lt;/P&gt;&lt;P&gt;0 - 1 = '0-1'&lt;/P&gt;&lt;P&gt;1 - 4= '1-4'&lt;/P&gt;&lt;P&gt;4-8='4-8'&lt;/P&gt;&lt;P&gt;8-high='8+';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=f.price_sas;&lt;/P&gt;&lt;P&gt;table a;&lt;/P&gt;&lt;P&gt;format a a_fmt.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set f.price_sas;&lt;/P&gt;&lt;P&gt;if a &amp;lt; 1 then new_a='0-1';&lt;/P&gt;&lt;P&gt;else if a &amp;lt; 4 then new_a='1-4'&lt;/P&gt;&lt;P&gt;else if new_a &amp;lt; 8 then new_a='4-8'&lt;/P&gt;&lt;P&gt;else if new_a&amp;gt;=8 then new_a='8+'&lt;/P&gt;&lt;P&gt;else new_a='CHECK ME';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=want;&lt;/P&gt;&lt;P&gt;table new_a;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:29:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question/m-p/121218#M33427</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-11-08T15:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question/m-p/121219#M33428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One method is to use formats to group the data into your bins.&amp;nbsp; For example to create the groupings for the first variable you could define a format named LEVELA as below and use it with PROC FREQ to count the number of observations that fall into each of the bins.&amp;nbsp; You can extend it to your other groupings by defining additional formats.&amp;nbsp; Note that if multiple variables use the same definitions for the bins then you just need to define on format and you can attach it to multiple variables using the FORMAT statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc format ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; value levela 0-1='0-1 $' 1-4='1-4 $' 4-8='4-8 $' 8-high='8+ $' other='Missing' ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc freq data=F.PRICE_SAS ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;tables a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;format a levela.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question/m-p/121219#M33428</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-11-08T15:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question/m-p/121220#M33429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot, your post were greatly helpful and made my code work !!&lt;/P&gt;&lt;P&gt;I am also very impressed by the speed of your replies !!&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question/m-p/121220#M33429</guid>
      <dc:creator>fredkho</dc:creator>
      <dc:date>2012-11-08T15:57:02Z</dc:date>
    </item>
  </channel>
</rss>

