<?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 SAS program in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568180#M11634</link>
    <description>&lt;P&gt;You can try this code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data Cache;
*Change the infile path below
	infile "~/stockprices.txt" dsd pad;
	input 
@1 Stock_symbol $4.
@5 Purchase_date mmddyy10.
@15 Purchase_price dollar6.2
@21 Number_of_shares 4.
@25 selling_date mmddyy10.
@35 selling_price dollar6.2;
	format Purchase_date date9.;
	format selling_date date9.;
	format Purchase_price dollar6.2;
	format selling_price dollar6.2;
run;

proc print data=Cache;
run;&lt;/PRE&gt;&lt;P&gt;One of the problems was you wanted the output format of Purchase_price and selling_price to be 11.2 initially but the data width is only 6 characters (including dollar symbol) .. so we have to adjust.. Let me know if it works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Sun, 23 Jun 2019 03:24:09 GMT</pubDate>
    <dc:creator>koyelghosh</dc:creator>
    <dc:date>2019-06-23T03:24:09Z</dc:date>
    <item>
      <title>Basic SAS program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568168#M11626</link>
      <description>&lt;P&gt;I am trying to print the following data using formatted input.&amp;nbsp; I am unable to print the purchase price and selling price. Where am i going wrong? I have attached a screenshot of the data and also my output.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Cache;
infile "/folders/myfolders/71442_example/stockprices.txt" dsd;
input 
@1 Stock_symbol $4.
@5 Purchase_date mmddyy10.
@15 Purchase_price 6.
@21 Number_of_shares 4.
@25 selling_date mmddyy10.
@35 selling_price 6.
;
format Purchase_date date9.;
format selling_date date9.;
format Purchase_price dollar11.2;
format selling_price dollar11.2;
run;

proc print data=Cache;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="D8.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30474i73BED2B5CBAB9032/image-size/large?v=v2&amp;amp;px=999" role="button" title="D8.png" alt="D8.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="D9.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30473i22C81F5E9E157D1B/image-size/large?v=v2&amp;amp;px=999" role="button" title="D9.png" alt="D9.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2019 00:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568168#M11626</guid>
      <dc:creator>cy_th</dc:creator>
      <dc:date>2019-06-23T00:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568169#M11627</link>
      <description>&lt;P&gt;Parts of your INPUT statement are wrong:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
@15 Purchase_price 6.
&lt;BR /&gt;
@35 selling_price 6.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since the raw data contains dollar signs, you must tell SAS about it so it knows to ignore them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
@15 Purchase_price dollar6.


@35 selling_price dollar6.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise, the dollar signs will be invalid characters for a numeric variable.&amp;nbsp; The log probably displayed a message about invalid data.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2019 01:12:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568169#M11627</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-06-23T01:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568171#M11628</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; is right but looking at the Purchase Price and selling price, I think you want the width to be 11 and you want 2 decimal places for the cents as well (after dollar). So you should instead use the below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;@Astounding is right but looking at the Purchase Price and selling price, I think you want the width to be 11 and you want 2 decimal places for the cents as well (after dollar). So you should instead use the below:

data Cache;
	infile "~/stockprices.txt" dsd;
	input 
@1 Stock_symbol $4.
@5 Purchase_date mmddyy10.
@15 Purchase_price dollar11.2
@21 Number_of_shares 4.
@25 selling_date mmddyy10.
@35 selling_price dollar11.2;
	format Purchase_date date9.;
	format selling_date date9.;
	format Purchase_price dollar11.2;
	format selling_price dollar11.2;
run;

proc print data=Cache;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2019 02:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568171#M11628</guid>
      <dc:creator>koyelghosh</dc:creator>
      <dc:date>2019-06-23T02:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568172#M11629</link>
      <description>Please replace the infile destination to where you want it to be .. I have used home directory ("~/") but you should change according to your infile path. Sorry about that</description>
      <pubDate>Sun, 23 Jun 2019 02:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568172#M11629</guid>
      <dc:creator>koyelghosh</dc:creator>
      <dc:date>2019-06-23T02:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568174#M11630</link>
      <description>&lt;P&gt;Thanks for your reply. I ran the code and I got this output. Why is it going wrong?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="D10.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30475iED296CA34C44773B/image-size/large?v=v2&amp;amp;px=999" role="button" title="D10.png" alt="D10.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2019 02:42:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568174#M11630</guid>
      <dc:creator>cy_th</dc:creator>
      <dc:date>2019-06-23T02:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568175#M11631</link>
      <description>&lt;P&gt;Will you please paste the log here?&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2019 02:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568175#M11631</guid>
      <dc:creator>koyelghosh</dc:creator>
      <dc:date>2019-06-23T02:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568178#M11632</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="D11.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30476iC1DD12EDB89555FB/image-size/large?v=v2&amp;amp;px=999" role="button" title="D11.png" alt="D11.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="D12.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30477i070918D1D932245C/image-size/large?v=v2&amp;amp;px=999" role="button" title="D12.png" alt="D12.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2019 02:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568178#M11632</guid>
      <dc:creator>cy_th</dc:creator>
      <dc:date>2019-06-23T02:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568179#M11633</link>
      <description>in the infile statement (just after dsd) if you add the option "PAD" .. does it help?</description>
      <pubDate>Sun, 23 Jun 2019 03:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568179#M11633</guid>
      <dc:creator>koyelghosh</dc:creator>
      <dc:date>2019-06-23T03:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568180#M11634</link>
      <description>&lt;P&gt;You can try this code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data Cache;
*Change the infile path below
	infile "~/stockprices.txt" dsd pad;
	input 
@1 Stock_symbol $4.
@5 Purchase_date mmddyy10.
@15 Purchase_price dollar6.2
@21 Number_of_shares 4.
@25 selling_date mmddyy10.
@35 selling_price dollar6.2;
	format Purchase_date date9.;
	format selling_date date9.;
	format Purchase_price dollar6.2;
	format selling_price dollar6.2;
run;

proc print data=Cache;
run;&lt;/PRE&gt;&lt;P&gt;One of the problems was you wanted the output format of Purchase_price and selling_price to be 11.2 initially but the data width is only 6 characters (including dollar symbol) .. so we have to adjust.. Let me know if it works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2019 03:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568180#M11634</guid>
      <dc:creator>koyelghosh</dc:creator>
      <dc:date>2019-06-23T03:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568181#M11635</link>
      <description>&lt;P&gt;Yes!! It's working now. Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2019 03:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568181#M11635</guid>
      <dc:creator>cy_th</dc:creator>
      <dc:date>2019-06-23T03:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568182#M11636</link>
      <description>If you like, you can mark the last post as a solution. All the best</description>
      <pubDate>Sun, 23 Jun 2019 03:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568182#M11636</guid>
      <dc:creator>koyelghosh</dc:creator>
      <dc:date>2019-06-23T03:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568244#M11642</link>
      <description>&lt;P&gt;Do NOT include decimal value in an INFORMAT unless you know that your source text has purposely NOT included the decimal point.&lt;/P&gt;
&lt;P&gt;If you do that and the values being read do NOT include a decimal point then the resulting value will be divided by the appropriate power of ten to insert the implied decimal point that your informat specified.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is generally easier to just add the TRUNCOVER option to handle short lines of data instead of asking SAS to pad the input buffer with spaces.&amp;nbsp; TRUNCOVER will also prevent SAS from going to a new line to look for data if a field is left blank.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2019 20:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568244#M11642</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-23T20:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS program</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568396#M11662</link>
      <description>&lt;P&gt;Instead of going through the extra steps of creating pictures of code or log just copy from the editor or log, open a code box on the forum with the {I} or "running man" icon and paste the text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That way 1) you save time 2) you don't have to deal with code / log results that exceed a window with multiple pictures, 2) we can copy and paste relevant bits and show the changes needed in the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know that I am not likely to retype a bunch of code to show one minor syntax change.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 15:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Basic-SAS-program/m-p/568396#M11662</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-06-24T15:36:37Z</dc:date>
    </item>
  </channel>
</rss>

