Reputation: 3576
I need to keep the definitions of the dataset I'm trying to create in the program. However as the incoming record length can be over 256 characters I'm getting the record split into two. If I had an external file I could use infile lrecl=1000
for example however with datalines
this option isn't available. Is there a way I can increase the record length while still using datalines
?
data output;
length value $500 ;
infile datalines dlm='#';
input id $ value $ ;
datalines ;
ID1#Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae risus nibh. Aliquam lacus sem, tempor sed scelerisque quis, blandit ut ante. Maecenas dapibus tellus dui, non congue risus auctor sit amet. Nulla fermentum ligula in leo vulputate accumsan. Ut aliquet vulputate nibh egestas faucibus. Donec elit mi, convallis sit amet interdum eu, tempus eu est. Donec elementum dapibus ipsum id bibendum. Phasellus in ex ut quam mollis congue. Nulla at augue facilisis, elementum felis euismod, accumsan arcu. Suspendisse lobortis iaculis odio, a suscipit quam.
;quit ;
The output dataset is then split like this:
ID VALUE
------------------------------------
ID1 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae risus nibh. Aliquam lacus sem, tempor sed scelerisque quis, blandit ut ante. Maecenas dapibus tellus dui, non congue risus auctor sit amet. Nulla fermentum ligula in leo vulputate accumsan.
Ut aliqu arcu. Suspendisse lobortis iaculis odio, a suscipit quam.
Upvotes: 0
Views: 474
Reputation: 63424
SAS pre-9.4 had a default LRECL of 256. While in DM this doesn't have any impact on the lrecl of a CARDS/DATALINES statement, this does affect input in batch mode, which is likely how you're submitting code.
You need to change the LRECL before system startup for this to work. Your best bet is to set the LRECL to something longer in your config file, by adding to the top of the file:
-LRECL 32767
(Or whatever shorter length you prefer.)
Example run with no LRECL modification in the config:
1 proc options option=lrecl;
SAS (r) Proprietary Software Release 9.3 TS1M2
LRECL=256 Default record length for external files
NOTE: PROCEDURE OPTIONS used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
2 data output;
3 length value $500 ;
4 infile datalines dlm='#';
5 input id $ value $ ;
6 length_value=length(value);
7 put value= length_value=;
8 datalines ;
WARNING: Truncated record.
value=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae risus
nibh. Aliquam lac
us sem, tempor sed scelerisque quis, blandit ut ante. Maecenas dapibus tellus du
i, non congue risu
s auctor sit amet. Nulla fermentum ligula in leo vulputate acc length_value=252
NOTE: The data set WORK.OUTPUT has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
10 ;
11 run;
Example run after modifying LRECL to 1024 in the config:
1 proc options option=lrecl;
SAS (r) Proprietary Software Release 9.3 TS1M2
LRECL=1024 Default record length for external files
NOTE: PROCEDURE OPTIONS used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
2 data output;
3 length value $500 ;
4 infile datalines dlm='#';
5 input id $ value $ ;
6 length_value=length(value);
7 put value= length_value=;
8 datalines ;
value=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae risus
nibh. Aliquam lac
us sem, tempor sed scelerisque quis, blandit ut ante. Maecenas dapibus tellus du
i, non congue risu
s auctor sit amet. Nulla fermentum ligula in leo vulputate accumsan. Ut aliquet
vulputate nibh ege
stas faucibus. Donec elit mi, convallis sit amet interdum eu, tempus eu est. Don
ec elementum dapib
us ipsum id bibendum. Phasellus in ex ut quam mollis congue. Nulla at augue faci
lisis, elementum f
elis euismod, ac length_value=500
NOTE: The data set WORK.OUTPUT has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
10 ;
11 run;
NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
real time 0.36 seconds
cpu time 0.40 seconds
Upvotes: 2
Reputation: 21274
The infile option is available.
Infile cards lrecl=500 truncover;
However the issue may be that your data contains line feeds. Look at it with a hex editor to see if any line feeds are present.
Upvotes: -1
Reputation: 9109
I can't reproduce your results please provide more information on the OS and BATCH vs EG/DMS etc. You may want to check related options like S
S=0
Option Definition Information for SAS Option S
Group= INPUTCONTROL
Group Description: Data entry and processing settings
Description: Length of source statements and data lines
Type: The option value is of type LONG
Range of Values: The minimum is 0 and the maximum is 9007199254740992
Valid Syntax(any casing): MIN|MAX|n|nK|nM|nG|nT|hexadecimal
Numeric Format: Usage of LOGNUMBERFORMAT does not impact the value format
When Can Set: Startup or anytime during the SAS Session
Restricted: Your Site Administrator can restrict modification of this option
Optsave: PROC Optsave or command Dmoptsave will save this option
SAS supports another form of in-stream data that it writes to a file defined by the PARMCARDS option the default is fileref FT15F001. You can try this version of your program and see if it fixes the problem.
filename FT15F001 temp lrecl=1024;
data output;
length value $1024;
infile FT15F001 dlm='#';
input id $ value $;
parmcards;
ID1#Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae risus nibh. Aliquam lacus sem, tempor sed scelerisque quis, blandit ut ante. Maecenas dapibus tellus dui, non congue risus auctor sit amet. Nulla fermentum ligula in leo vulputate accumsan. Ut aliquet vulputate nibh egestas faucibus. Donec elit mi, convallis sit amet interdum eu, tempus eu est. Donec elementum dapibus ipsum id bibendum. Phasellus in ex ut quam mollis congue. Nulla at augue facilisis, elementum felis euismod, accumsan arcu. Suspendisse lobortis iaculis odio, a suscipit quam.
;;;;
run;
Upvotes: 1