12-19-2011 01:52 AM
i want to import data from txt file into sas system.
The size of raw data file is to big,and the length of the record is also to big,what i know is that the values are separated by comma.
What problem i am facing is that i dont know how my variables values it holds in a record.it many 120 variables or even mre then that.
i want to access a variable values and want to create sas data set.
12-19-2011 08:20 AM
Does the data file have a header record that contains the variable names? Have you tried using proc import, indicating that it is a csv file? Have you looked at the raw file with a text editor like Wordpad (not Notepad, as it has a hard time with large files)?
12-19-2011 08:50 AM
You can explore the content of your text file with SAS.
If you want to see what it looks like use the LIST statement in a data step. If there are any non-printable characters in the lines then SAS will show you the hex codes for those characters.
* Dump first 5 lines to the log ;
infile 'myfile.txt' lrecl=32676 ;
if _n_ >= 5 then stop;
If you know that it is comma delimited then you try just pulling in a few rows into character variables and see what you have .
* Pull in first 50 columns for first 10 rows ;
data sample ;
infile 'myfile.txt' dsd dlm=',' truncover lrecl=32676 ;
length x1-x50 ;
input x1-x50 ;
if _n_ >= 10 then stop;
If you have figured out how to read it and due to space issues you only want to keep a couple of columns then you could use a KEEP (or DROP) statement or dataset option.
data subset (keep=id age sex);
infile 'myfile.txt' dsd dlm=',' truncover ;
input id start end age weight height sex comment ;