Hi,
How to read a data from an external file and store it in a variable.
For example,
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.
Thanks,
Abhi
Hi mate,
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
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?
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.
Just like
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*/
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.