BookmarkSubscribeRSS Feed
75063
Obsidian | Level 7

I am using SAS on demand for academics and want to import a CSV file with 200 variables and 350 observations. 

 

I imported by using the code - 

 

filename tiger '/home/user/username/State.csv';
Proc Import datafile= tiger DBMS = csv OUT=libname.Statea ;
GUESSINGROWS= All;
run;

 

A sample of the csv is -  

 

43 
22The career services office was not very helpful. I talked with them a few timesdo, not for those who want because all they did was tell me stuff I already knew and then said "you know what you want, now just go find it." I would have thought that they would be more helpful in actually finding a job. help actually finding a job. and then gave up They seem to be an office for those who have no idea what they want to 

 

when the csv file was read in sas the contents of the third column extended to the other columns - just as - 

 

 

37 
The career services office was not very helpful. I talked with them a few timesdo, not for those who stuff I already knew and then said "you know wT want because all they did was tell me hat you want, now just go find it." I would have thought that they would be more helpful in actually finding a job. help actually finding a job. and then gave up They seem to be an office for those who have no idea what they want to 

 

 

 

 

Can someone please suggest how to read the CSV file in sas using "SAS on demand for academics" having a variable with a long string as shown above.  

 

Thank you!

 

6 REPLIES 6
andreas_lds
Jade | Level 19

This does not look like a csv-file! Please open the file with a text editor and post some lines using "insert sas code" or the {i}-icon

grafik.png

75063
Obsidian | Level 7
The original file was an xlsx file which I saved as a CSV file. The issue
that i am facing is that the long string is being read into multiple
observation leading to erroneous results
Kurt_Bremser
Super User

@75063 wrote:
The original file was an xlsx file which I saved as a CSV file. The issue
that i am facing is that the long string is being read into multiple
observation leading to erroneous results

OK, and where is the example? We can't help you without actual data to test code against.

ballardw
Super User

@75063 wrote:
The original file was an xlsx file which I saved as a CSV file. The issue
that i am facing is that the long string is being read into multiple
observation leading to erroneous results

If at all practical I would see if this Excel file was exported from some other application. If so, see if that source could create a delimited file other than comma, perhaps a pipe character, |,  and import that. The mixture of quotes and commas imbedded in your text makes this a very poor candidate for CSV.

 

Or perhaps save as simple open xml and use the SAS XML mapper to attempt to read the file.

Kurt_Bremser
Super User

Your sample does not show a csv file, as a csv file is text with the columns separated by commas. Please post an actual sample of the csv as attachment or into a {i} window.

 

Note that you have commas and quotes in your texts, so this will make it very hard for SAS to make any sense out of it.

I strongly recommend to not use proc import for data like this, but roll your own data step. We may be able to help you once we have a good example of your input data.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Whilst I agree with all posted before, and that what is posted is not sufficient to really post any further help, I would also ask, what do you intend to do with this data?  A big block of text is pretty much useless to anyone, next to impossible to process in any meaningful way.  So maybe just drop it?

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1948 views
  • 0 likes
  • 5 in conversation