BookmarkSubscribeRSS Feed
Quartz | Level 8

hi all,

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.

proc import

    datafile = "have.csv"

    out = test

    dbms = csv;

    delimiter = ";";



Anyone has a suggestion for taking care of that multi-line observations? really appreciate it!

Obsidian | Level 7

Hey Shayan,

     Please use the below code and check.

data XYZ ;

infile "have.csv" DLM=';';

length filename$ 500;

input filename@@ ;



Diamond | Level 26 RW9
Diamond | Level 26


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:

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.

Super User

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@@ ;

Xia Keshan


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


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
  • 3 replies
  • 4 in conversation