<?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: Rounding up month to two decimal place in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735729#M28689</link>
    <description>&lt;P&gt;So you want to convert strings into numbers?&amp;nbsp; How consistent are the strings?&amp;nbsp; Are they as messy as your examples?&lt;/P&gt;
&lt;PRE&gt;4 years
8month
6years&lt;/PRE&gt;
&lt;P&gt;Can we assume there is always a space between the digits and the letters?&lt;/P&gt;
&lt;PRE&gt;4 years
8 month
6 years&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Apr 2021 19:00:34 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-04-20T19:00:34Z</dc:date>
    <item>
      <title>Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735678#M28678</link>
      <description>&lt;P&gt;I have a variable "time_on_team" that has both year and month values and I want to format the variable and say the month is year/12 and I want to put around it to 2 decimal place. How do you around the year/12 to two decimal place?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;length Yrson 8.;&lt;BR /&gt;if (time_on_Team)= 'year'&amp;nbsp; then YrsOn= 'Year';&lt;BR /&gt;else if (time_on_team)='month' then YrsOn='year'/12;&lt;BR /&gt;drop time_on_team;&lt;BR /&gt;label YrsOnARV = 'Years on ARVs';&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 17:15:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735678#M28678</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-04-20T17:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735683#M28679</link>
      <description>&lt;P&gt;You can use the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/p0tj6cmga7p8qln1ejh6ebevm0c9.htm" target="_self"&gt;ROUND function&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, your code can't possibly work, dividing a character string by 12. Get as much of the code to work before worrying about rounding.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 17:20:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735683#M28679</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-20T17:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735684#M28680</link>
      <description>&lt;P&gt;This answers your question&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;YrsOn = round(YrsOn, 0.01);
format YrsOn 8.2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I don't think this is correct: YRSON would now be a character variable, not numeric as you've assigned it the value "Year" and I would assume your ELSE line of code would generate an error. Are you trying to access a variable called year? If so, remove the quotes from around the name as that's a character string, not a variable name.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length Yrson 8.;
if (time_on_Team)= 'year'  then YrsOn= 'Year';
else if (time_on_team)='month' then YrsOn='year'/12;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have a variable year you could also refer to it as 'Year'n but if the n does not follow the quote then it will be interpreted as a character string, not a variable name. I don't think this is your issue however.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a variable "time_on_team" that has both year and month values and I want to format the variable and say the month is year/12 and I want to put around it to 2 decimal place. How do you around the year/12 to two decimal place?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;length Yrson 8.;&lt;BR /&gt;if (time_on_Team)= 'year'&amp;nbsp; then YrsOn= 'Year';&lt;BR /&gt;else if (time_on_team)='month' then YrsOn='year'/12;&lt;BR /&gt;drop time_on_team;&lt;BR /&gt;label YrsOnARV = 'Years on ARVs';&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 17:24:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735684#M28680</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-20T17:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735685#M28681</link>
      <description>How can i say year/12?  I didnt know if it was going to work&lt;BR /&gt;else if (time_on_team)='month' then YrsOn='year'/12;</description>
      <pubDate>Tue, 20 Apr 2021 17:26:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735685#M28681</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-04-20T17:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735689#M28682</link>
      <description>&lt;P&gt;Please show an example of your data.&lt;/P&gt;
&lt;P&gt;Does the variable TIME_ON_TEAM have the strings YEAR and MONTH?&amp;nbsp; Or does it have a number?&lt;/P&gt;
&lt;P&gt;If it has a number then how can you tell if the number is a number of months or number of years?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 17:39:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735689#M28682</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-20T17:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735691#M28683</link>
      <description>&lt;P&gt;'year' is a character string, which cannot be divided by 12&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;year is (possibly, I don't know your data) a variable name, and if this variable is numeric, it can be divided by 12&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 17:41:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735691#M28683</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-20T17:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735701#M28684</link>
      <description>the variable YearOn has values like ( 4 years, 8month, 6years etc..) and I want the month values to be divided by 12. How can i do that in the if/then statement?</description>
      <pubDate>Tue, 20 Apr 2021 17:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735701#M28684</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-04-20T17:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735706#M28685</link>
      <description>&lt;P&gt;As stated above by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;, please show us a portion of your data. Please follow &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt; and do not show us your data via any other method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 18:05:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735706#M28685</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-20T18:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735721#M28686</link>
      <description>my data is very big but, this is how it looks like&lt;BR /&gt;ID	Time_on_team&lt;BR /&gt;1	2years&lt;BR /&gt;2	6years&lt;BR /&gt;3	6month&lt;BR /&gt;4	10years&lt;BR /&gt;5	4month&lt;BR /&gt;6	8month&lt;BR /&gt;I am trying to find the range, mean, sd, IQR median for time_on_team</description>
      <pubDate>Tue, 20 Apr 2021 18:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735721#M28686</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-04-20T18:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735725#M28687</link>
      <description>&lt;P&gt;Showing a portion of the data is fine. However, the specific request was "&lt;SPAN&gt;Please follow&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self" rel="nofollow noopener noreferrer"&gt;these instructions&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;and do not show us your data via any other method."&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 18:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735725#M28687</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-20T18:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735727#M28688</link>
      <description>my data is very big but, this is how it looks like&lt;BR /&gt;ID Time_on_team&lt;BR /&gt;1 2years&lt;BR /&gt;2 6years&lt;BR /&gt;3 6month&lt;BR /&gt;4 10years&lt;BR /&gt;5 4month&lt;BR /&gt;6 8month&lt;BR /&gt;I am trying to find the range, mean, sd, IQR median for time_on_team</description>
      <pubDate>Tue, 20 Apr 2021 18:50:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735727#M28688</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-04-20T18:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735729#M28689</link>
      <description>&lt;P&gt;So you want to convert strings into numbers?&amp;nbsp; How consistent are the strings?&amp;nbsp; Are they as messy as your examples?&lt;/P&gt;
&lt;PRE&gt;4 years
8month
6years&lt;/PRE&gt;
&lt;P&gt;Can we assume there is always a space between the digits and the letters?&lt;/P&gt;
&lt;PRE&gt;4 years
8 month
6 years&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 19:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735729#M28689</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-20T19:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735730#M28690</link>
      <description>yes</description>
      <pubDate>Tue, 20 Apr 2021 19:02:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735730#M28690</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-04-20T19:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735732#M28691</link>
      <description>I want to use an if then stament &lt;BR /&gt;like this below. but, the one i created doesnt work&lt;BR /&gt;length Yrson 8.;&lt;BR /&gt;if (time_on_Team)= 'year'  then YrsOn= 'Year';&lt;BR /&gt;else if (time_on_team)='month' then YrsOn='year'/12;&lt;BR /&gt;drop time_on_team;&lt;BR /&gt;label YrsOn = 'Years on Team';</description>
      <pubDate>Tue, 20 Apr 2021 19:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735732#M28691</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-04-20T19:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up month to two decimal place</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735733#M28692</link>
      <description>&lt;P&gt;First parse the string into two parts.&amp;nbsp; The digits and they units. Convert the digits into a number.&amp;nbsp; Then based on whether the units indicate months divide the number by 12.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So assuming you have only the two forms and the values have a space&amp;nbsp;it is really easy.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  id+1;
  input time_on_team $20.;
cards;
2 years
6 years
6 month
10 years
4 month
8 month
;

data want;
  set have;
  duration=input(scan(time_on_team,1,' '),32.);
  if index(time_on_team,'month') then duration=duration/12;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;             time_on_
Obs    id      team      duration

 1      1    2 years       2.0000
 2      2    6 years       6.0000
 3      3    6 month       0.5000
 4      4    10 years     10.0000
 5      5    4 month       0.3333
 6      6    8 month       0.6667
&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Apr 2021 19:12:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rounding-up-month-to-two-decimal-place/m-p/735733#M28692</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-20T19:12:32Z</dc:date>
    </item>
  </channel>
</rss>

