03-15-2016 02:23 PM
How to read a data from an external file and store it in a variable.
Say i have a external file with 62K thousand records. There is no space delimiters nothing. However, i need to read 1 to 30k records and store it A variable and 30K to 60l records i need to store it in B variable. Please guide me how i can achieve.
03-15-2016 02:56 PM - edited 03-15-2016 03:04 PM
Try to use the infile and input:
One for the first 30000 values: Infile "Your-file.txt" dlm = " " firstobs=1 obs=30000; input #1 entire_row1 $1-220; One for the last values: Infile "Your-file.txt" dlm = " " firstobs=30000 obs=62000; input #1 entire_row2 $1-220;
Hope this helps
03-16-2016 12:00 AM
03-15-2016 05:02 PM
It's a bit unclear what you want to do.
Do you have a text file that is just...text...no natural variables...?
And then, you want to store 30K (no of?) records (how long is a record) into a variable. A data set variable?
Could it be that you are mixing up the terminology. 30K of text (chars), into one variable...?
Then, I'm a bit curious, what's the application?
03-15-2016 11:58 PM
03-16-2016 08:37 AM
In my guess, Linus, he want to split his import in two variables.
From the line 1 to 32k will be set in variable A and the last lines will be set in variable B.
infile "file" firstobs=1 obs=32000;
input Entire_Row1 $1-220; /*This var starts in line one until 32k*/
input Entire_Row2 $1-220; /*This var starts in line 32001 until 62k*/