0
votes

is it possible to read only specific variabiles from text files into sas as sas dataset using proc import? I have very big data in my text file which contains like 1000 observations and more than 42,000 variables. I tried reading this file into sas using proc import but i failed in doing so i thought may be because of size issues. Now i decided to read only specific variables (columns) really i do not need all of them from this big text file so that i can reduce size of file to read into sas system. is there any ideas to read like this by using data step? Suggestion or help would be appreciated

Thanking you very much,

1
Which version of sas are you using?Michael Richardson
That must be an enormous text file.Michael Richardson
42k variables = 8 bytes per, let's say = 350kb per observation; so 350MB or so. Not that enormous... but also probably not very well organized (not that i'm surprised, the stat world does a terrible job of thinking about data management for the most part).Joe
i am using sas 9.2 versionuser2134713

1 Answers

1
votes

If you're talking about a delimited text file, you can read in specific variables, contingent on them being consecutive from the first variable. You can't use PROC IMPORT to do this, however; you'd have to write the datastep yourself, though you could conceivably have PROC IMPORT help you write it.

For example, if you have 10 variables and only want the first 3, then you can read it in like this:

data want;
infile "mydata.txt" dlm=',' lrecl=255 missover dsd;
input x $ y $ z $;
run;

However, you must read in all variables from the first variable to the last variable you are interested in, even if you aren't interested in all of the intermediate variables. You can't "skip" them with a delimited text file.

If you have a fixed width text file, you can read in whatever columns you want (but you can't use PROC IMPORT to read in a fixed width text file).