<?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: Calculate quartiles and assign them to if then statement in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Calculate-quartiles-and-assign-them-to-if-then-statement/m-p/724938#M9879</link>
    <description>Thanks for your help. I should have asked my question better. I know how to use proc format with a dataset, but combining it with other procs is what i do not know how to do. I tried applying it with the proc ranks above and i could not figure it out</description>
    <pubDate>Tue, 09 Mar 2021 18:30:50 GMT</pubDate>
    <dc:creator>jude1</dc:creator>
    <dc:date>2021-03-09T18:30:50Z</dc:date>
    <item>
      <title>Calculate quartiles and assign them to if then statement</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Calculate-quartiles-and-assign-them-to-if-then-statement/m-p/724919#M9873</link>
      <description>&lt;P&gt;I'm trying to find the quartiles for a variable in my data set, then create a new variable that takes different values depending on the quartile.&amp;nbsp;&lt;/P&gt;&lt;P&gt;4 if the percentage for&amp;nbsp; var1 is greater than the third quartile&lt;BR /&gt;3 if the percentage for&amp;nbsp; var1 is between the median &amp;amp; the third quartile&lt;BR /&gt;2 if the percentage for&amp;nbsp; var1 is between the first quartile &amp;amp; the median&lt;BR /&gt;1 if the percentage for&amp;nbsp; var1 is lower than the first quartile&lt;BR /&gt;. ( missing value) if the percentage is not given&lt;BR /&gt;Format the new_var to name the groups “high”, “med-high”, “med-low”, and “low”, respectively. Add a label to the variable as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my data looks like this:&lt;/P&gt;&lt;P&gt;data mydata;&lt;/P&gt;&lt;P&gt;input var1 income location percentage;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 500 ny 100%&lt;/P&gt;&lt;P&gt;2 400 nj 90%&lt;/P&gt;&lt;P&gt;3 400 ma 80%&lt;/P&gt;&lt;P&gt;4 800 va 80%&lt;/P&gt;&lt;P&gt;5 500 ca 75%&lt;/P&gt;&lt;P&gt;6 600 ma 70%&lt;/P&gt;&lt;P&gt;7 900 wv 60%&lt;/P&gt;&lt;P&gt;8 1000 ny 50%&lt;/P&gt;&lt;P&gt;9 100 pa 40%&lt;/P&gt;&lt;P&gt;10 760 wy 20%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 17:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Calculate-quartiles-and-assign-them-to-if-then-statement/m-p/724919#M9873</guid>
      <dc:creator>jude1</dc:creator>
      <dc:date>2021-03-09T17:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate quartiles and assign them to if then statement</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Calculate-quartiles-and-assign-them-to-if-then-statement/m-p/724922#M9874</link>
      <description>&lt;P&gt;PROC RANK will obtain the quartiles (although it will produce values 0 to 3 instead of 1 to 4, I leave that conversion up to you as a homework assignment, although its totally unnecessary to do given that you are going to assign words like "high" to these values).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=mydata groups=4 out=want;
    var var1;
    ranks new_var;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can create a custom format to assign the words like "high" to your quartiles. Example of creating a custom format:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=proc&amp;amp;docsetTarget=n03qskwoints2an1ispy57plwrn9.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=proc&amp;amp;docsetTarget=n03qskwoints2an1ispy57plwrn9.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/369737"&gt;@jude1&lt;/a&gt;&amp;nbsp;, we have a request so you can help us out in the future. Please provide your data with WORKING SAS code, not the code you provided which doesn't exactly work. That will help you get better and quicker answers.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 17:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Calculate-quartiles-and-assign-them-to-if-then-statement/m-p/724922#M9874</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-09T17:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate quartiles and assign them to if then statement</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Calculate-quartiles-and-assign-them-to-if-then-statement/m-p/724938#M9879</link>
      <description>Thanks for your help. I should have asked my question better. I know how to use proc format with a dataset, but combining it with other procs is what i do not know how to do. I tried applying it with the proc ranks above and i could not figure it out</description>
      <pubDate>Tue, 09 Mar 2021 18:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Calculate-quartiles-and-assign-them-to-if-then-statement/m-p/724938#M9879</guid>
      <dc:creator>jude1</dc:creator>
      <dc:date>2021-03-09T18:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate quartiles and assign them to if then statement</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Calculate-quartiles-and-assign-them-to-if-then-statement/m-p/724944#M9880</link>
      <description>&lt;P&gt;When you try to use data set WANT, apply the format then.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 18:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Calculate-quartiles-and-assign-them-to-if-then-statement/m-p/724944#M9880</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-09T18:52:21Z</dc:date>
    </item>
  </channel>
</rss>

