use of dlm and dlmstr during infile

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

use of dlm and dlmstr during infile

Hi, all.

I am trying to read in a .csv data.

Its original extension was .xlsx and my SAS version is 9.2(TS1MO), which does not support .xlsx,  so I asked the owner of this file to convert it to .csv file.

But the problem is that it seems like to have two delimeter. There are 10 variables which is seperated by ',' (usual delimiter for .csv) but each observation is seperated by '^M'.

When I open it with vi(I am using Linux), it looks liks below..

L1,L2,L3,L4,L5,L6, L7, L8, L9, L10^MBEER/ALE/ALCOHOLIC,DOMESTIC,MONKS ALE,ALE BEER 72OZ,9,08-01-94922-00101, 8, 1,94922,  101^MBEER/ALE/ALCOHOLIC,DOMESTIC BEER/ALE, \BEER LNBCN 72OZ,9,08-01-94922-00101, 8, 1,94922,  101^MBeer....

So I tried to use dlmstr and dlm together as it is shown below

data aa;

infile "/data/kanishka/d1/2013iridata/parsedstubfiles2008-2011/prod11_beer.csv" dlmstr='^M' dlm=',' lrecl=100000 truncover;

input L1$ L2$ L3$ L4$ L5$ L6$ L7$ L8$ L9$ L$10;

run;

But I only could bring the first line of the data (variable line...) and it does not show any data after the first ^M

Does anyone have a better idea which can improve this SAS code?

And am I allowed to use both dlmstr and dlm at the same time?

Thanks!

Jin-Hee Huh


Accepted Solutions
Solution
‎03-14-2013 12:24 AM
Super User
Super User
Posts: 7,050

Re: use of dlm and dlmstr during infile

Looks like it was created on a MAC. The carriage returns are not delimiters between values, but end of line markers. Use TERMSTR= option.

infile  "....."  truncover firstobs=2 DLM=',' TERMSTR=CR lrecl=10000;

View solution in original post


All Replies
Solution
‎03-14-2013 12:24 AM
Super User
Super User
Posts: 7,050

Re: use of dlm and dlmstr during infile

Looks like it was created on a MAC. The carriage returns are not delimiters between values, but end of line markers. Use TERMSTR= option.

infile  "....."  truncover firstobs=2 DLM=',' TERMSTR=CR lrecl=10000;

Contributor
Posts: 20

Re: use of dlm and dlmstr during infile

Thanks! I found it before you answer. It worked and you are right!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 488 views
  • 0 likes
  • 2 in conversation