I am relatively new to SAS programming. The state has modified how they want their data files. They used to want .dat files and now have changed to .csv files with 2 header records (second one has the column headings). What is the best way to do this in a SAS program?
Here is SAS code that demonstrates how to use a DATA step to generate a CSV file with two lines for heading
data _NULL_;
set sashelp.class; /* replace with your data set name */
file 'c:\temp\test.csv' dlm=',';
if _N_ = 1 then do;
put 'first line heading'; /* replace with your heading */
put 'name,age,sex,height,weight'; /* replace with your variables */
end;
put name age sex height weight; /* replace with your variables */
run;
If you have more then 256 characters per output line, you need an LRECL parameter on the FILE statement.
I invite you to send email to support.sas.com if you have further questions.
Jan
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.