DATA Step, Macro, Functions and more

SAS dataset export to a foxpro DBF

Reply
Occasional Contributor
Posts: 19

SAS dataset export to a foxpro DBF

I am exporting a dataset to DBF.  The export works but there are decimals in every variable.

 

PROC EXPORT DATA=Test1
outfile='F:\\hq2sso19.dbf'
DBMS=DBFMEMO REPLACE;
RUN;

 

Is it possible to set a variable type in the export or is this a procedure before exporting?  I need to export as numerica fields no decimals for Foxpro Version 8.0.

 

Thanks

overky

Super User
Posts: 11,343

Re: SAS dataset export to a foxpro DBF

I doubt that you will have any luck with Proc Export. Export is very limited in options and none control output formats.

You have a couple choices. One if your license for SAS is correct would be to use Proc DBLOAD to write the file direct to the dbf file. That allows setting formats. Here is what an example from the documentation looks like:

PROC DBLOAD DBMS=DBFMEMO DATA=employee;
  PATH='c:\sasdemo\employee.dbf';
  RENAME firstname = fname;
  TYPE   empid     = 'numeric(6)'
         hiredate  = 'date'
         salary    = 'numeric(10,2)'
         jobcode   = 'numeric(5)';
  RUN;

 

Though DBLOAD seems to imply DBase not Foxpro

Another possible option would be to use the Proc Export to write a CSV file and control options on inporting that file into the DBF.

Occasional Contributor
Posts: 19

Re: SAS dataset export to a foxpro DBF

When I try that code, I get the following:

 

This DBLOAD compatibility procedure does not support full screen features.

 

Also will this statement accept a replace command so that the DBF file is overwritten each time the SAS is executed?

 

 

Super User
Super User
Posts: 7,039

Re: SAS dataset export to a foxpro DBF

Do your variables have formats attached?  I am pretty sure that PROC EXPORT to DBF format will use the format attached to your variable when deciding how to create the field in the DBF file.

 

Occasional Contributor
Posts: 19

Re: SAS dataset export to a foxpro DBF

Not that I am aware of.  

 

 My code reads in a txt file with a DLM of "\"

 Takes that dataset and then needs to export as a dbf.

Super User
Super User
Posts: 7,039

Re: SAS dataset export to a foxpro DBF

So define formats for your numbers and see what happens.

 

data XXX ;
   infile .... .;
   input .... ;
   format AGE 3. ;
run;

proc export ....
Occasional Contributor
Posts: 19

Re: SAS dataset export to a foxpro DBF

I am not sure I am explaining very well...

 

 I have:

500.00   

600.00

700.00

 

But I need

500

600

700

 

 I need my dbf fields without decimals  my dataset does not have decimals but when I export to a dbf it creates decimals.

Super User
Super User
Posts: 7,039

Re: SAS dataset export to a foxpro DBF

[ Edited ]

Have in what sense?  If you have a SAS dataset then you have IEEE 8 byte floating point numbers. In that situation there is no difference between 700.00 and 700 since they are both seven hundred.

Perhaps you mean that you currently have attached a format like 6.2 to your variable so that when it prints you always see two digits to the right of the decimal place.

data have ;
  input x ;
  format x 6.2 ;
cards;
500
600
700
;

In that case attach a DIFFERENT format so that PROC EXPORT knows not to include the decimal places.

data to_export;
  set have ;
  format x 3. ;
run;
proc export data=to_export out='myfoxpro.dbf' dbms=dbf;
run;
Ask a Question
Discussion stats
  • 7 replies
  • 140 views
  • 0 likes
  • 3 in conversation