hi all
i created a datastep to generate a delimited csv file.Code as below:
Sources Code:
data _null_;
set etllib._101100_MonthlyDSFACT;
FILE DelSum DLM=',' notitles header=headrtne;
PUT WhsCode :$8.
DocDate :yymmddn8.
DocDueDate :yymmddn8.
ItemCode :$20.
Quantity ;
return;
headrtne:
PUT @1 'WhsCode,DocDate,DocDueDate,ItemCode,Quantity';
return;
run;
Output: DelSum_20111012.csv
WhsCode,DocDate,DocDueDate,ItemCode,Quantity
B09,20110926,20110926,10423632,2
WhsCode,DocDate,DocDueDate,ItemCode,Quantity
B11,20110926,20110926,10421902,1
My Expected Output is like this
WhsCode,DocDate,DocDueDate,ItemCode,Quantity
B09,20110926,20110926,10423632,2
B11,20110926,20110926,10421902,1
How can i do so with the data step.
beside, i tried before using proc export to done the job.its provide me the nice output except the date format is following the sas date format
/*
proc export data=etllib._101100_MonthlyDSFACT
file="F:\abc\&&FileNameD%sysfunc(putn(&&Todaydate,yymmddn8.))&&Extension"
dbms=csv
Replace;
run;
*/
Is there other way to deal with it?
Please help.
Thank you:
LiangCk
Liang,
I think you only need something like:
ata _null_;
set etllib._101100_MonthlyDSFACT;
FILE DelSum DLM=',';
if _n_ eq 1 then
PUT @1 'WhsCode,DocDate,DocDueDate,ItemCode,Quantity';
PUT WhsCode :$8.
DocDate :yymmddn8.
DocDueDate :yymmddn8.
ItemCode :$20.
Quantity ;
run;
Liang,
I think you only need something like:
ata _null_;
set etllib._101100_MonthlyDSFACT;
FILE DelSum DLM=',';
if _n_ eq 1 then
PUT @1 'WhsCode,DocDate,DocDueDate,ItemCode,Quantity';
PUT WhsCode :$8.
DocDate :yymmddn8.
DocDueDate :yymmddn8.
ItemCode :$20.
Quantity ;
run;
Hi art,
Thanks, i get what i wanted
Apperciate it.
LiangCk
How about:
data _null_;
set sashelp.class;
FILE print DLM=',' notitles header=headrtne;
PUT names $8.
weight ;
return;
headrtne :
PUT @1 'name,weight';
run;
Ksharp
Ksharp
I like the idea, but it needs that $8. removed or prefixed with :
Attempting to generalise suggested
%let list = age
name height weight ;
%let dlm = %str(,) ;
data _null_;
set sashelp.class( keep=&list);
FILE print DLM= "&dlm" notitles header=headrtne;
PUT (&list)(:);
return;
headrtne :
PUT @1 "%sysfunc( translate( %sysfunc( compbl( &list)), %str(&dlm), %str( ) ))" ;
run;
but I'm not sure how well it would work with a tab delimiter
peterC
You do not what to use HEADER option on the FILE statement to generate a CSV file.
It will only work with the PRINT option but then it will also generate page breaks (formfeeds) and extra header lines.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.