11-19-2014 05:23 PM
so I need to import a csv file, delimited by ; , to a sas data set.
heres an idea of the data:
aaa; bbb; ccc
xxx; yyy; zzz
ppp; jjj; aaaaa...
so, in the third abservation, the variable is long so that it goes to the next line of the csv file.
when I write some simple import proc like the below, it recognizes these new lines as new variables.
datafile = "have.csv"
out = test
dbms = csv;
delimiter = ";";
Anyone has a suggestion for taking care of that multi-line observations? really appreciate it!
11-20-2014 04:24 AM
Can I check, do you mean that the line in your text editor just wraps due to space limitations in the editor, or that there is actually embedded line break codes within that data. The way to do this is to use a free Hex editor (Google, there is lots of free ones), goto a place where you know there is a break and look at the actual Hex code where the line splits. If you see 0A0D or similar then you have more problems than just a long string. Have a look at my post here: https://communities.sas.com/thread/60374
Where I have some correspondence with Tech Support.
If its just a long of text (and why would you have text that long anyways?) something like GokulShivananda has posted would be suggested. As always I would avoid the use of proc import at all. Write the code yourself and you know what your data looks like and what you want, proc import is all guess work. If you have further problems with the code above, remember the infile options - lrecl, dsd, missover etc.
11-20-2014 08:54 AM
You should throw proc import away under this situation. use recfm=n to take it as a stream file.
filename x 'c:\temp\have.txt'; data have; infile x DLM=';' recfm=n; length filename$ 500; input filename@@ ; run;