Hey all! Thank you in advance for reading and thank you doubly should you try and assist.
So I am trying to export a CSV file with no header row, ~ as the delimiter, and a | character (I think this the pipe character) as the record delimiter.
So I have this wrapped up in a macro:
FILENAME dlmTest &fileName lrecl=50000;
DATA _NULL_;
SET &dataSet;
FILE dlmTest
DSD
RECFM=N
LRECL=50000
DLM='~';
PUT (_ALL_) (+0);
RUN;
I found, as part of the FILE syntax, RECFM but I'm running into a series of problems.
The file always automatically inserts the CRLF when generating unless I have RECFM=N
(the option for fixed length won't work, since my fields are variable length).
When I use RECFM=N, it would almost work except it adds an additional ~ after each line.
As part of my data set, I found I could add a column that just put in the pipe I needed as I didn't see an obvious way to add this in normally.
My question ultimately is how to generate, for multiple records, a single line of output for a CSV without CRLF automatically added and without adding the extra ~ to the end of the record.
Thanks for any help you can provide!
John
data _null_,
Thank you very much for your help, that worked perfectly!
Now I am off to go read why that worked.
Thanks again!
John
DN,
I look up some docs, but still not 100% positive on the usage of (:). Is its purpose to add a blank after each variable?
Thanks,
Haikuo
In order to put (_ALL_) in parenthesis, in order to switch its meaning from "put program data vector" to "variable list" we need to follow with the parenthesized list of (format specifications/pointer control). The OP used +0 for the same reason but for some unknown reason I don't like +0.
I can't be nothing.
To arrive at an understanding of the syntax of what data _null_; originally supplied, I utilized the following two documents:
SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition
http://www2.sas.com/proceedings/sugi26/p073-26.pdf
I was looking in the wrong place for what I was trying to do, trying to manipulate the file instead of what was actually being put into the file - that was my mistake.
Now I am much more enlightened to the extent and power of the PUT statement thanks to DN and this wonderful documentation.
Thanks again!
John
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.