Here you go
%let path =%sysfunc(pathname(work));
%let csv_file =test.csv;
/* create sample .csv */
data _null_;
file "&path\&csv_file";
infile datalines4;
input;
put _infile_;
datalines4;
First Name,Last Name, NPN/A#,Order Date,Quantity,Item Product Name,Item Price,User Role,User State,User Home Market,CMS
Order #: O-AMS123,,,,,,,,,,
Document #: D-AMS342,,,,,,,,,,
Kain,Flory,34566732 ,12/28/2023,1,Sample sample,$0.00 ,BRKR,LA ,,Sample1
Order #: O-AMS797,,,,,,,,,,
Document #: D-AMS562,,,,,,,,,,
James,Brown,34589732 ,12/28/2023,1,Sample sample,$0.00 ,BRKR,LA ,,Sample2
Johny,David,34589452 ,12/28/2023,1,Sample sample,$0.00 ,BRKR,LA ,,Sample3
;;;;
/* read sample .csv into SAS table */
data want;
attrib
order length=$15 informat=$15.
document length=$15 informat=$15.
first_name length=$40 informat=$40.
last_name length=$40 informat=$40.
/* ...and so on ... */
;
retain order document;
infile "&path\&csv_file" truncover dsd dlm=',' firstobs=2;
input order_ind:$8. @;
if order_ind='Order #:' then
do;
input @9 order;
input @12 document;
end;
input @1
first_name
last_name
/* ...and so on ... */
;
drop order_ind;
run;
proc print data=want;
run;
... View more