<?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: Problem understanding date and dollar formats in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Problem-understanding-date-and-dollar-formats/m-p/765369#M30551</link>
    <description>&lt;P&gt;Minor addition: Unless you really know what "implied decimal" means and is used for do not use the decimal portion of an &lt;STRONG&gt;informat&lt;/STRONG&gt;. If you specify a decimal portion on an informat and the text value does not actually contain a decimal value then the informat would imply a value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   input amount :comma12.2;
datalines;
$456.38           /*ignores currency symbol*/
456.38
$45,638            /*ignores currency symbol and implies decimal*/
;
&lt;/PRE&gt;
&lt;P&gt;If in the above case you want a value of 45638 for the third value use the Comma12. informat to avoid implying a decimal that is not there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This behavior for informats is partially related to ancient days of data entry and keypunch card data where there was limited space on the cards. By implying a position for the decimal they did not actually use that print position on the card allowing more data per card.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Sep 2021 14:32:40 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-09-01T14:32:40Z</dc:date>
    <item>
      <title>Problem understanding date and dollar formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Problem-understanding-date-and-dollar-formats/m-p/765282#M30546</link>
      <description>&lt;P&gt;Hello Team, I have serious problems understanding the date and dollar formats. In fact, in certain exercises, dollar7 or a dollar12 are sometimes used. Can you better explain to me when should I use dollar7, dollar8 dollar9, dollar10, dollar11, or dollar12&lt;/P&gt;&lt;P&gt;here is an example I got I used dollar12. but in the correction one uses dollar7. and I can't understand the reasons they gave. It's the same problem with the date format using date7, date8 date 9, and so on.&lt;/P&gt;&lt;PRE&gt;data results.output13;
  set cert.input13;
  Chdate=put(date1,date9.);
  num1=input(Charnum,dollar7.);
run;&lt;/PRE&gt;&lt;P&gt;Thank's for your comprehension&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 10:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Problem-understanding-date-and-dollar-formats/m-p/765282#M30546</guid>
      <dc:creator>serges007</dc:creator>
      <dc:date>2021-09-01T10:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problem understanding date and dollar formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Problem-understanding-date-and-dollar-formats/m-p/765285#M30547</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;start with reading the doc:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n11m54nggvjybhn1w2a8mbczw04q.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n11m54nggvjybhn1w2a8mbczw04q.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;for dateW. format: "Writes date values in the form ddmmmyy, ddmmmyyyy, or dd-mmm-yyyy."&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n16vcb736tge20n1ex3yxx49fzqa.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n16vcb736tge20n1ex3yxx49fzqa.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;for dollarW.D format: "&lt;SPAN&gt;Writes numeric values with a leading dollar sign, a comma that separates every three digits, and a period that separates the decimal fraction.&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/p03sgbuduqemljn1nqj7qm1leql9.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/p03sgbuduqemljn1nqj7qm1leql9.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;W - indicates width of a text printed by format, D - indicates number of digits&amp;nbsp;to the right of the decimal point&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 10:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Problem-understanding-date-and-dollar-formats/m-p/765285#M30547</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-09-01T10:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Problem understanding date and dollar formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Problem-understanding-date-and-dollar-formats/m-p/765327#M30550</link>
      <description>&lt;P&gt;The first thing you need to learn is the difference between a &lt;STRONG&gt;FORMAT&lt;/STRONG&gt; and an &lt;STRONG&gt;INFORMAT&lt;/STRONG&gt;.&amp;nbsp; Your code is using one of each.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="5"&gt;Formats convert values into text.&amp;nbsp; Informats convert text into values.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DOLLAR &lt;STRONG&gt;format&lt;/STRONG&gt; writes numeric values with a $ prefix and thousand separators.&amp;nbsp; There isn't any DOLLAR &lt;STRONG&gt;informat&lt;/STRONG&gt;.&amp;nbsp; But SAS will recognize DOLLAR as an alias for the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n1dvsmv8t9o60gn1dk1gkev91nan.htm" target="_self"&gt;COMMA informat&lt;/A&gt;. That informat will ignore $ and commas in the source string when converting the string into a number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The w.d part of a format or informat specification indicates the number to total characters and the number of characters after the decimal point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note than when using the INPUT() function, as in your second example, it does not mind if you use a width on the informat specification that is larger than the length of the text string you are asking it to convert.&amp;nbsp; So unless there are trailing characters in that text string you want INPUT() to ignore you are probably best off just using a large number for the width.&amp;nbsp; Note that each informat (or format) will have a maximum width that it supports that you can find in the documentation for the informat (or format).&amp;nbsp; For the COMMA informat you are using the maximum width is 32.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 12:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Problem-understanding-date-and-dollar-formats/m-p/765327#M30550</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-01T12:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Problem understanding date and dollar formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Problem-understanding-date-and-dollar-formats/m-p/765369#M30551</link>
      <description>&lt;P&gt;Minor addition: Unless you really know what "implied decimal" means and is used for do not use the decimal portion of an &lt;STRONG&gt;informat&lt;/STRONG&gt;. If you specify a decimal portion on an informat and the text value does not actually contain a decimal value then the informat would imply a value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   input amount :comma12.2;
datalines;
$456.38           /*ignores currency symbol*/
456.38
$45,638            /*ignores currency symbol and implies decimal*/
;
&lt;/PRE&gt;
&lt;P&gt;If in the above case you want a value of 45638 for the third value use the Comma12. informat to avoid implying a decimal that is not there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This behavior for informats is partially related to ancient days of data entry and keypunch card data where there was limited space on the cards. By implying a position for the decimal they did not actually use that print position on the card allowing more data per card.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 14:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Problem-understanding-date-and-dollar-formats/m-p/765369#M30551</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-01T14:32:40Z</dc:date>
    </item>
  </channel>
</rss>

