<?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: Percents and Dollar values in datalines in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Percents-and-Dollar-values-in-datalines/m-p/354230#M82837</link>
    <description>&lt;P&gt;Okay this is the final solution - I changed the values of the percents. Thank you both for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  infile datalines;
  format Current_Cost dollar6.2 Target percent8.2;
  input Current_Cost Target;
  datalines;
40 .7641
30 .7621
20 .5036
10 .2022
23 .2491
45 .8612
;;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Apr 2017 18:40:10 GMT</pubDate>
    <dc:creator>JediApprentice</dc:creator>
    <dc:date>2017-04-27T18:40:10Z</dc:date>
    <item>
      <title>Percents and Dollar values in datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percents-and-Dollar-values-in-datalines/m-p/354199#M82823</link>
      <description>&lt;P&gt;I'm trying to manually generate data with the datalines statement. I can't seem to figure out how to properly get correct values for percents and dollar values. This is what I have right now. Have tried different formats but can't get it to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  infile datalines;
  format Current_Cost dollar3.2 Target percent8.2;
  input Current_Cost dollar3.2 Target percent8.2;
  datalines;
$40.00 76.41%
$30.00 76.21%
$20.00 50.36%
$10.00 20.22%
$23.00 24.91%
$45.00 86.12%
;;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want them to display exactly as they are in the datalines. But right now it is coming out as this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8586i870F145198CA14AE/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 17:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percents-and-Dollar-values-in-datalines/m-p/354199#M82823</guid>
      <dc:creator>JediApprentice</dc:creator>
      <dc:date>2017-04-27T17:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Percents and Dollar values in datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percents-and-Dollar-values-in-datalines/m-p/354201#M82824</link>
      <description>&lt;P&gt;First, get rid of the unneeded characters in your inputs, so that the inputs are entirely numeric (and a decimal point).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, you don't need the informats in the INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the dollars to come out as $40.00 then you want format DOLLAR5.2 (or bigger, such as DOLLAR10.2, if you will have many more digits to the LEFT of the decimal point.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I leave it up to you to play with the format for percent until you get it to work the way you want it.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 17:07:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percents-and-Dollar-values-in-datalines/m-p/354201#M82824</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-04-27T17:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Percents and Dollar values in datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percents-and-Dollar-values-in-datalines/m-p/354205#M82826</link>
      <description>&lt;P&gt;For your exampe:&lt;/P&gt;
&lt;PRE&gt;data test;
  infile datalines truncover;
  format Current_Cost dollar6.2 Target percent8.2;
  input Current_Cost dollar6.2 Target percent8.2 ;
  datalines;
$40.00 76.41%
$30.00 76.21%
$20.00 50.36%
$10.00 20.22%
$23.00 24.91%
$45.00 86.12%
;;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Problems: when you say 3.2 you mean read a value with a length of 3 characters and 2 of them are decimals. So a Dollar3.2 format has lots of problems as the $ takes one position, the . takes a second and that doesn't leave much. You need to count every likely displayed character in the w part of a format that has the w.d option to set the W part. Your informat of percent failed because you requested 8 characters but the value only had 6. So the line of data ran out. The TRUNCOVER option says to read what is present and truncate the data.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 17:17:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percents-and-Dollar-values-in-datalines/m-p/354205#M82826</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-27T17:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Percents and Dollar values in datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percents-and-Dollar-values-in-datalines/m-p/354230#M82837</link>
      <description>&lt;P&gt;Okay this is the final solution - I changed the values of the percents. Thank you both for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  infile datalines;
  format Current_Cost dollar6.2 Target percent8.2;
  input Current_Cost Target;
  datalines;
40 .7641
30 .7621
20 .5036
10 .2022
23 .2491
45 .8612
;;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2017 18:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percents-and-Dollar-values-in-datalines/m-p/354230#M82837</guid>
      <dc:creator>JediApprentice</dc:creator>
      <dc:date>2017-04-27T18:40:10Z</dc:date>
    </item>
  </channel>
</rss>

