<?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: Format variables in dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Format-variables-in-dataset/m-p/520639#M141218</link>
    <description>&lt;P&gt;Your code did not use the informat if as posted:&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token statement"&gt;informat&lt;/SPAN&gt; Hdate mmddyy10&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&amp;nbsp; there should be a period at the end of the informat:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token statement"&gt;informat&lt;/SPAN&gt; Hdate mmddyy10&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data likely&amp;nbsp;was read properly but you have not given&amp;nbsp;SAS any&amp;nbsp;instruction to display the value as a date.&lt;/P&gt;
&lt;P&gt;So add a format statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token statement"&gt;format&lt;/SPAN&gt; Hdate mmddyy10. &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;again make sure that the format ends with a period.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Dec 2018 00:26:05 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-12-12T00:26:05Z</dc:date>
    <item>
      <title>Format variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-variables-in-dataset/m-p/520633#M141215</link>
      <description>&lt;P&gt;Can someone help me adjust the below code so that values show for both the "salary" and "hdate" variables?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename sales1 "/folders/myfolders/sascode/sales1.txt";
data US_trainees AU_trainees;
	infile sales1;
	input ID 1-6 LName $ 21-39 
		  Title $ 43-63 Salary 64-72 Country $ 73-75 
		  Hdate:mmddyy10 87-97;
	informat Hdate mmddyy10;
	
	if country = "US" then output US_trainees;
		else output AU_trainees;
		
		keep ID Lname Title Salary Hdate;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Dec 2018 00:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-variables-in-dataset/m-p/520633#M141215</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-12T00:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: Format variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-variables-in-dataset/m-p/520635#M141217</link>
      <description>&lt;P&gt;I adjusted the code so now it doesn't show blanks, but it lists the dates as 4 digit numbers with some being positive and others negative. Any advice?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 00:14:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-variables-in-dataset/m-p/520635#M141217</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-12T00:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Format variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-variables-in-dataset/m-p/520639#M141218</link>
      <description>&lt;P&gt;Your code did not use the informat if as posted:&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token statement"&gt;informat&lt;/SPAN&gt; Hdate mmddyy10&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&amp;nbsp; there should be a period at the end of the informat:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token statement"&gt;informat&lt;/SPAN&gt; Hdate mmddyy10&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt; ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data likely&amp;nbsp;was read properly but you have not given&amp;nbsp;SAS any&amp;nbsp;instruction to display the value as a date.&lt;/P&gt;
&lt;P&gt;So add a format statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token statement"&gt;format&lt;/SPAN&gt; Hdate mmddyy10. &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;again make sure that the format ends with a period.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 00:26:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-variables-in-dataset/m-p/520639#M141218</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-12T00:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Format variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-variables-in-dataset/m-p/520706#M141229</link>
      <description>&lt;P&gt;Please post a few example lines from your external file, so we have something to test code against.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 08:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-variables-in-dataset/m-p/520706#M141229</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-12T08:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: Format variables in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-variables-in-dataset/m-p/520712#M141230</link>
      <description>&lt;P&gt;Here a comprehensive example with data taken from your &lt;A href="https://communities.sas.com/t5/New-SAS-User/How-to-create-dataset-from-raw-data-file/m-p/520588" target="_blank"&gt;other thread&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data us australia;
input
  @1  id $6.
  @21 lname $18.
  @43 title $20.
  @64 salary dollar8.
  @73 country $2.
  @76 bdate mmddyy10.
  @87 hdate mmddyy10.
;
format
  salary dollar8.
  bdate hdate mmddyy10.
;
select (country);
  when ('AU') output australia;
  when ('US') output us;
  otherwise;
end;
cards;
120102 Tom          Zhou               M  Sales Manager        $108,255 AU 08/11/1969 06/01/1989
120103 Wilson       Dawes              M  Sales Manager         $87,975 AU 01/22/1949 01/01/1974
120121 Irenie       Elvish             F  Sales Rep. II         $26,600 AU 08/02/1944 01/01/1974
120261 Harry        Highpoint          M  Chief Sales Officer  $243,190 US 02/21/1969 08/01/1987
121018 Julienne     Magolan            F  Sales Rep. II         $27,560 US 01/03/1944 01/01/1974
121019 Scott        Desanctis          M  Sales Rep. IV         $31,320 US 06/25/1986 06/01/2004
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Dec 2018 08:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-variables-in-dataset/m-p/520712#M141230</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-12T08:18:32Z</dc:date>
    </item>
  </channel>
</rss>

