<?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: How to write a .dbf file and specify its format in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-write-a-dbf-file-and-specify-its-format/m-p/36327#M9124</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You cannot use a FORMAT statement to change the length of the character variables.&amp;nbsp; You can change the length by using a data step or proc sql statement to create the variable with a different length.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot change the 16 spaces that SAS uses to store the numeric fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the link to the SAS 9.2 documentation: &lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://support.sas.com/documentation/cdl/en/acpcref/63184/HTML/default/viewer.htm#a003087278.htm"&gt;http://support.sas.com/documentation/cdl/en/acpcref/63184/HTML/default/viewer.htm#a003087278.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;Converting SAS Variables to DBF Fields&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Numeric variables are stored in character form by DBF files. SAS numeric variables become numeric variables with a length of 16 when converted from a DBF file. SAS decimal values must be stored in a decimal format to be converted to a DBF decimal value. Associate the SAS numeric variable with an appropriate decimal format. The corresponding DBF field does not have any value to the right of the decimal point. You can associate a format with SAS variables when you create the data set or with the DATASETS procedure.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;If the number of digits including a possible decimal point exceeds 16, a warning message is issued and the DBF numeric field is filled with the character 9 . All SAS character variables become DBF fields of the same length. When you convert a SAS data set to a DBF file that is compatible with dBASE III or later, SAS date variables become DBF date fields. When you convert a SAS data set to a dBASE II file, SAS date variables become dBASE II character fields in the form YYYYMMDD.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Jul 2011 18:03:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2011-07-25T18:03:51Z</dc:date>
    <item>
      <title>How to write a .dbf file and specify its format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-write-a-dbf-file-and-specify-its-format/m-p/36326#M9123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to output a sas dataset to a .dbf file.&amp;nbsp; I also would like to specify the field format for the columns of data in the .dbf file.&amp;nbsp; The dbf procedure documentation seems to imply that I can do this with a format statement.&amp;nbsp; I've tried the following syntax:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LIBNAME mylib 'u:\';&lt;/P&gt;&lt;P&gt;FILENAME test 'u:\test.dbf';&lt;/P&gt;&lt;P&gt;PROC DBF DB3=test DATA=wbhat;&lt;/P&gt;&lt;P&gt;FORMAT wb $6. mg 3.0 age 1.0;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code successfully creates a .dbf file but the field width of the character variable (wb) is 5 characters, not the 6 that I specified.&amp;nbsp; Also, the numeric fields are 16 digits wide, not the 3 and 1 that I specified.&amp;nbsp; Is it possible to specify the column field widths of a .dbf file created from sas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 17:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-write-a-dbf-file-and-specify-its-format/m-p/36326#M9123</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2011-07-25T17:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a .dbf file and specify its format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-write-a-dbf-file-and-specify-its-format/m-p/36327#M9124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You cannot use a FORMAT statement to change the length of the character variables.&amp;nbsp; You can change the length by using a data step or proc sql statement to create the variable with a different length.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot change the 16 spaces that SAS uses to store the numeric fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the link to the SAS 9.2 documentation: &lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://support.sas.com/documentation/cdl/en/acpcref/63184/HTML/default/viewer.htm#a003087278.htm"&gt;http://support.sas.com/documentation/cdl/en/acpcref/63184/HTML/default/viewer.htm#a003087278.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;Converting SAS Variables to DBF Fields&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Numeric variables are stored in character form by DBF files. SAS numeric variables become numeric variables with a length of 16 when converted from a DBF file. SAS decimal values must be stored in a decimal format to be converted to a DBF decimal value. Associate the SAS numeric variable with an appropriate decimal format. The corresponding DBF field does not have any value to the right of the decimal point. You can associate a format with SAS variables when you create the data set or with the DATASETS procedure.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;If the number of digits including a possible decimal point exceeds 16, a warning message is issued and the DBF numeric field is filled with the character 9 . All SAS character variables become DBF fields of the same length. When you convert a SAS data set to a DBF file that is compatible with dBASE III or later, SAS date variables become DBF date fields. When you convert a SAS data set to a dBASE II file, SAS date variables become dBASE II character fields in the form YYYYMMDD.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 18:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-write-a-dbf-file-and-specify-its-format/m-p/36327#M9124</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-07-25T18:03:51Z</dc:date>
    </item>
    <item>
      <title>How to write a .dbf file and specify its format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-write-a-dbf-file-and-specify-its-format/m-p/36328#M9125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tom.&amp;nbsp; That is the exact documentation that I was refering to.&amp;nbsp; With poorly structured sentences like "Associate the SAS numeric variable with an appropriate decimal format." it is difficult to understand what they are trying to say.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, it sounds like from your response that there is a way to change character fields but the integer fields will always be 16 in a dbf file created by sas.&amp;nbsp; Is that correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am a beginning sas user so examples really help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 18:13:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-write-a-dbf-file-and-specify-its-format/m-p/36328#M9125</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2011-07-25T18:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a .dbf file and specify its format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-write-a-dbf-file-and-specify-its-format/m-p/36329#M9126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To change the length of a variable you need to create a new dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length wb $6 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set wbhat ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you really care if the DBF file has numeric or character variables?&amp;nbsp; You could convert AGE to $1 using a PUT function call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set wbhat (rename=(age = numeric_age) );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; age = put(age,1.) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop numeric_age ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are more comfortable with SQL syntax then use PROC SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table new as &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select wb as wb length=6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , put(age,1.) as age length=1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , put(mg,3.) as mg length=3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from wbhat&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 18:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-write-a-dbf-file-and-specify-its-format/m-p/36329#M9126</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-07-25T18:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a .dbf file and specify its format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-write-a-dbf-file-and-specify-its-format/m-p/36330#M9127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data class;set sashelp.class;run;
proc sql noprint;
 alter table class
&amp;nbsp;&amp;nbsp; modify sex char(20);
quit;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jul 2011 04:57:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-write-a-dbf-file-and-specify-its-format/m-p/36330#M9127</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-07-26T04:57:23Z</dc:date>
    </item>
  </channel>
</rss>

