Hello,
I have a file with varying row lengths. I only want one variable in my table that has each full fow in it.
This is what I have so far and it doesn't bring in the full row
data temp ;
infile file1 lrecl=390000 ;
input x $ ;
run ;
I know it's something simple, but I can't seem to figure it out.
Thank you
I was unable to modify my reply, could only post the code. You can't have a variable in SAS longer than 32767 so you will need to read each line into more than one variable. My example shows how that can be done. Change 40 to something larger up to 32767. The array diminsion will need to change also to suite your needs.
It would be helpful to know what you would do with the record as variable(s).
filename FT15F001 temp;
data lines;
infile FT15F001 truncover;
array part[3] $40.;
input (part[*])($char40.);
parmcards;
this is the data line this is the line this is the data line
this is the data line this is the data line this is the data line this is the data line
this is the data line this is the data line this is the data line
;;;;
run;
This example shows how you might read each recored in a file into a number of variables up to 32767 in length.
thank you data_null_,
I need each row to come in as a single row. The lengths of each row vary and they are larger then 32767.
Is that the max length of a character variable field?
I was unable to modify my reply, could only post the code. You can't have a variable in SAS longer than 32767 so you will need to read each line into more than one variable. My example shows how that can be done. Change 40 to something larger up to 32767. The array diminsion will need to change also to suite your needs.
It would be helpful to know what you would do with the record as variable(s).
Thank you so much.
I need to add more data to the end of each row for use in another process.
That did it. I tested it with one row and I was able to split it up and add the data to the end then put it into another text file.
Thank you
I thought you might say that. To copy records and add data to the end you don't need to create a SAS data set of the input file. You can do everything in one DATA _NULL_ ...
data _null_; infile FT15F001 lrecl=%sysevalf(32767*2); /*LRECL larger than 32767 means no _INFILE_ variable*/ input; set sashelp.class(obs=3); file log ls=256; /*You will use FILENAME and LRECL appropriate to your application*/ put _infile_ +1 'New at end ' (_all_)(=); /*_INFILE_ is not a variable but a put statement directive*/ parmcards; this is the data line this is the line this is the data line this is the data line this is the data line this is the data line this is the data line this is the data line this is the data line this is the data line ;;;; run;
I like that approach better. I like that it is all in one data step.
Thank you again
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.