Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

comma delimited

Status
Not open for further replies.

DKY

Programmer
Mar 18, 2005
2
US
I uploaded a .CSV file and it now has double quotes and periods in it so I'm trying to read it in as a delimited file to no avail. I have data that looks like:
.~".R.o.w. .#.".,.".S.D.A.T.E.".,.".L.E.V.E.L.1.".,.".L.E.V.E.L.2.".,.".S._.P.R.
.".1.".,.".0.8./.3.0./.2.0.1.0.".,.".0.0.0.0.1.1.5.0.".,.".L.E.G.:.7.7.7.".,."."
.".2.".,.".0.8./.3.0./.2.0.1.0.".,.".0.0.0.0.1.1.5.0.".,.".L.E.G.:.7.8.1.".,."."
.".3.".,.".0.8./.3.0./.2.0.1.0.".,.".0.0.0.0.1.2.5.0.".,.".L.E.G.:.7.7.0.".,."."
.".4.".,.".0.8./.3.0./.2.0.1.0.".,.".0.0.0.0.1.2.5.0.".,.".L.E.G.:.7.7.5.".,."."
.".5.".,.".0.8./.3.0./.2.0.1.0.".,.".0.0.0.0.1.2.5.0.".,.".L.E.G.:.7.7.7.".,."."
.".6.".,.".0.8./.3.0./.2.0.1.0.".,.".0.0.0.0.1.2.5.0.".,.".L.E.G.:.7.8.1.".,."."
.".7.".,.".0.8./.3.0./.2.0.1.0.".,.".0.0.0.0.1.2.6.0.".,.".L.E.G.:.7.7.0.".,."."
.".8.".,.".0.8./.3.0./.2.0.1.0.".,.".0.0.0.0.1.2.6.0.".,.".L.E.G.:.7.7.6.".,."."
.".9.".,.".0.8./.3.0./.2.0.1.0.".,.".0.0.0.0.1.2.6.0.".,.".L.E.G.:.7.7.7.".,."."
.".1.0.".,.".0.8./.3.0./.2.0.1.0.".,.".0.0.0.0.1.2.6.0.".,.".L.E.G.:.7.8.1.".,."
.".1.1.".,.".0.8./.3.0./.2.0.1.0.".,.".0.1.0.0.1.2.5.0.".,.".L.E.G.:.7.7.0.".,."
.".1.2.".,.".0.8./.3.0./.2.0.1.0.".,.".0.1.0.0.1.2.5.0.".,.".L.E.G.:.7.7.5.".,."
.".1.3.".,.".0.8./.3.0./.2.0.1.0.".,.".0.1.0.0.1.2.5.0.".,.".L.E.G.:.7.7.7.".,."
.".1.4.".,.".0.8./.3.0./.2.0.1.0.".,.".0.1.0.0.1.2.5.0.".,.".L.E.G.:.7.8.1.".,."
.".1.5.".,.".0.8./.3.0./.2.0.1.0.".,.".0.1.0.0.2.1.9.5.".,.".L.E.G.:.7.7.0.".,."
.".1.6.".,.".0.8./.3.0./.2.0.1.0.".,.".0.1.0.0.2.1.9.5.".,.".L.E.G.:.7.7.5.".,."
.".1.7.".,.".0.8./.3.0./.2.0.1.0.".,.".0.1.0.0.2.1.9.5.".,.".L.E.G.:.7.7.6.".,."
.".1.8.".,.".0.8./.3.0./.2.0.1.0.".,.".0.1.0.0.2.1.9.5.".,.".L.E.G.:.7.7.7.".,."

and my sas to read it in looks like:
DATA A;
INFILE FCST12C DLM=',' LRECL=100 FIRSTOBS=2;
INPUT
ROW:$20.
FDATE:$27.
NAV_PN $
PDC $
OLDFCST $
CURFCST $
RCRDTYPE $
;

Is there a way to get rid of the double quotes and the periods in the infile statement?
 

Here is code, try this-

data a1;
set a;
row = compress (row, '" " ');
fdate= compress (fdate, '" " ');
nav_pn= compress (nav_pn, '" "');
pdc= compress (pdc, '" "');
oldfcst= compress (oldfcst, '" "');
curfcst= compress (curfcst, '" "');
rcrdtype= compress (rcrdtype, '" "');
run;
 
And for periods you can use same method, instead of " " you should put .
 
here is total code-

data a1;
set a;
row = compress (row, '" " ');
fdate= compress (fdate, '" " ');
nav_pn= compress (nav_pn, '" "');
pdc= compress (pdc, '" "');
oldfcst= compress (oldfcst, '" "');
curfcst= compress (curfcst, '" "');
rcrdtype= compress (rcrdtype, '" "');
run;

data a1;
set a1;
row = compress (row, '.. .. ');
fdate= compress (fdate, '.. .. ');
nav_pn= compress (nav_pn, '.. ..');
pdc= compress (pdc, '.. ..');
oldfcst= compress (oldfcst, '.. ..');
curfcst= compress (curfcst, '.. ..');
rcrdtype= compress (rcrdtype, '.. ..');
run;
 
Ah, compress. Why didn't I see that? Thanks! This works!

Code:
ROW = COMPRESS(COMPRESS(ROW, '"'), '00'X);
FDATE = COMPRESS(COMPRESS(FDATE, '"'), '00'X);
NAV_PN = COMPRESS(COMPRESS(NAV_PN, '"'), '00'X);
PDC = COMPRESS(COMPRESS(PDC, '"'), '00'X);
OLDFCST = COMPRESS(COMPRESS(OLDFCST, '"'), '00'X);
CURFCST = COMPRESS(COMPRESS(CURFCST, '"'), '00'X);
RCRDTYPE = COMPRESS(COMPRESS(RCRDTYPE, '"'), '00'X);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top