BookmarkSubscribeRSS Feed
myoung27
Calcite | Level 5
I'm importing a file from Cobol into SAS and am encountering a problem with two packed decimal fields in the conversion. As the fields are read in, some of the unpacked results read out to the equivalent of hex values 00 or 1A, and therefore my data step thinks it is at the end of a row prematurely. Is there any simple way to either a) simply skip over these fields when reading the file into SAS or b)Tell SAS to disregard the hex equivalents for those fields so each line goes to the full lrecl?
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Hi:
My COBOL days are a bit behind me -- several jobs ago, but this note about the correct INFORMATS and how they correspond to COBOL PIC definitions may be useful:
http://support.sas.com/kb/3/714.html

Before you assume that the problem is in the data, I would be sure that you are using the correct INFORMAT on the SAS side to read the data. Here's some more information on reading binary and packed decimal data:
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a003209921.htm

cynthia
DanielSantos
Barite | Level 11
Are you dealing with fixed or variable block files?

Anyway, please share with us the code you are using to import the file.

Cheers from Portugal.

Daniel Santos @ www.cgd.pt
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Also, on what OS are running SAS? What OS does your data originate and how is it created? If the two OS platforms are not the same, how do you transfer (FTP, IND$FILE, and with what parameters) the data from the originating OS platform to the OS platform where you are running SAS to process the data? It would be most useful if you posted a REPLY with the SAS log pasted in it, for others to review -- also with all of your DATA and/or PROC step code revealed.

Scott Barry
SBBWorks, Inc.
data_null__
Jade | Level 19
You don't mention OS but I'm thinking Windows, where the default is files that use "control character" to delimit records. This is fine for reading most data but when the data can have any value from 00x to FFx there can be problems. There are two ways in SAS that I know of to ignore record markers. RECFM = N or F. I think you need RECFM=F because you mention records and COBAL and record length. So on the FILENAME statement or the INFILE statement you need RECFM=F and LRECL=. The following example although contrived and cryptic illustrates the difference that these options can make.

[pre]
830 filename FT44F001 temp;
831 data _null_;
832 file FT44F001;
833 do x = '00'x,'1A'x;
834 put 'Hello' x $1.;
835 put x $1. 'hello';
836 end;
837 run;

NOTE: The file FT44F001 is:
File Name=C:\DOCUME~1\userid\LOCALS~1\Temp\SAS Temporary Files\_TD3336\#LN00024,
RECFM=V,LRECL=256

NOTE: 4 records were written to the file FT44F001.
The minimum record length was 6.
The maximum record length was 6.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds


838 Confusion:
839 data _null_;
840 infile FT44F001;
841 input;
842 list;
843 run;

NOTE: The infile FT44F001 is:
File Name=C:\DOCUME~1\userid\LOCALS~1\Temp\SAS Temporary Files\_TD3336\#LN00024,
RECFM=V,LRECL=256

RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0

1 CHAR Hello. 6
ZONE 466660
NUMR 85CCF0



RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0

2 CHAR .hello 6
ZONE 066666
NUMR 085CCF
3 Hello 5
NOTE: 3 records were read from the infile FT44F001.
The minimum record length was 5.
The maximum record length was 6.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


844 Bliss:
845 data _null_;
846 infile FT44F001 recfm=f lrecl=8;
847 input;
848 list;
849 run;

NOTE: The infile FT44F001 is:
File Name=C:\DOCUME~1\userid\LOCALS~1\Temp\SAS Temporary Files\_TD3336\#LN00024,
RECFM=F,LRECL=8

RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0

1 CHAR Hello...
ZONE 46666000
NUMR 85CCF0DA

2 CHAR .hello..
ZONE 06666600
NUMR 085CCFDA

3 CHAR Hello...
ZONE 46666100
NUMR 85CCFADA



RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0

4 CHAR .hello..
ZONE 16666600
NUMR A85CCFDA
NOTE: 4 records were read from the infile FT44F001.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

[/pre]

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1668 views
  • 0 likes
  • 5 in conversation