BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tosin
Calcite | Level 5

I have to import a DBF file with a specified layout, so i dont want to use the proc import because sometimes the proc runs wrong...

 

When i try to import the DBF file using the infile statement, only the first line is loaded to the dataset..... Warning and errors dont appear in the log...

 

How can i do this import?

 

Thank you.

 

data work.benefpagos;
    infile '/sasdata/BSEG/HOLDING/riscos_ctba/solucoes/dataset/dev/BENEFPAGOS.DBF'
        LRECL=183
        encoding="LATIN1"
        termstr=crlf
	missover
	dsd;
    input   COD_CIA          : $CHAR5.
	        DT_SOLIC         : $CHAR8.
	        NOM_PARTIC       : $CHAR30.
	        NUM_PROP         : $CHAR10.
	        NUM_PROC         : $CHAR20.
	        TIPO_PROD        : BEST32.
	        TIPO_PLANO       : BEST32.
	        CPF_PARTIC       : $CHAR11.
	        NOM_BENEF        : $CHAR30.
	        CPF_BENEF        : $CHAR11.
	        CNPJ_CIA         : $CHAR14.
	        DT_EVENTO        : $CHAR8.
	        VR_PROV          : BEST32.
	        DT_PAGTO         : $CHAR8.
	        VR_PAGO          : BEST32. ;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You might want to explain exactly what you mean by :"i dont want to use the proc import because sometimes the proc runs wrong"

One of the issues with DBF if that the same extension is used for multiple actual file types. Plus additional headaches if there is a MEMO field such as

PROC IMPORT OUT=WORK.TEST
    DATAFILE='orders.dbf'
    DBMS=DBFMEMO REPLACE;
RUN;

Note: Any DBF file that you plan to import to a SAS data set should be in a tabular format. All items in a given column should represent the same type of data. If the DBF file contains inconsistent data, such as a row of underscores, hyphens, or blanks, delete these rows before converting the file. It is recommended that you make a backup copy of your DBF table before you make these modifications.

 

You might be able to use PROC DBF

Example:

proc dbf db2='/sasdata/BSEG/HOLDING/riscos_ctba/solucoes/dataset/dev/BENEFPAGOS.DBF'
     out=work.benefpagos;
run; 

if your file is DB3 or DB4 then use either of those in place of DB2= in the code above.

 

 

 

 

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

You cannot read .dbf files with a data step, a they are not pure text files.

If you have SAS/ACCESS to PC Files licensed, you can use proc import with dbms=dbf.

ballardw
Super User

You might want to explain exactly what you mean by :"i dont want to use the proc import because sometimes the proc runs wrong"

One of the issues with DBF if that the same extension is used for multiple actual file types. Plus additional headaches if there is a MEMO field such as

PROC IMPORT OUT=WORK.TEST
    DATAFILE='orders.dbf'
    DBMS=DBFMEMO REPLACE;
RUN;

Note: Any DBF file that you plan to import to a SAS data set should be in a tabular format. All items in a given column should represent the same type of data. If the DBF file contains inconsistent data, such as a row of underscores, hyphens, or blanks, delete these rows before converting the file. It is recommended that you make a backup copy of your DBF table before you make these modifications.

 

You might be able to use PROC DBF

Example:

proc dbf db2='/sasdata/BSEG/HOLDING/riscos_ctba/solucoes/dataset/dev/BENEFPAGOS.DBF'
     out=work.benefpagos;
run; 

if your file is DB3 or DB4 then use either of those in place of DB2= in the code above.

 

 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1271 views
  • 0 likes
  • 3 in conversation