Read a line of texts treating each word as a variable

I have a text file in which there are data entries like this:

apple orange fish meet kite stone

I want to create a SAS dataset like this:

VAR1 <-- this is variable name.
apple
orange
fish

*************

Hi,

To read a record which contains multiple values and create multiple observations with 1 variable, you can use the INPUT statement with the double trailing @. I created a sample record with your data and then used the DATA step with INFILE and INPUT statement to read in the data to create multiple observations with 1 variable. Here is the code:

data one;
infile 'c:\temp\input2.txt';
input v1 $ @@;
run;

proc print;
run;

Here are the results from PROC PRINT:

Obs v1

1 apple
2 orange
3 fish
4 meet
5 kite
6 stone
<Thanks,AE>

Leave a Reply