Please post an example as TEXT (either attach as a .txt file or paste into the Insert Code pop-up window). It sounds like you are saying you have CSV file with one line and two columns that looks like:
"site_id = '0', pt_initials = 'AA', dob = '1800-01-01', sex = '1', form_3_followup_complete = '0', study_id = '000'","fup_cont_attemp = '1', fup_time = '30', fup_yesno = '0', fup_nocall = '2', fup_date = '1900-01-01 13:30', fup_comment = 'weather is nice today'"
You could convert that into a file that just has the comma separated NAME=VALUE pairs.
data _null_;
infile 'original.csv' dsd truncover ;
file 'step1.csv' ;
length cell $32767. ;
do until (cell=' ');
input cell :$32767. @;
put cell ',' @;
end;
put +(-1) ' ' ;
run;
site_id = '0', pt_initials = 'AA', dob = '1800-01-01', sex = '1', form_3_followup_complete = '0', study_id = '000',fup_cont_attemp = '1', fup_time = '30', fup_yesno = '0', fup_nocall = '2', fup_date = '1900-01-01 13:30', fup_comment = 'weather is nice today'
Then you could read in the name=value pairs and then parse them.
data tall ;
infile 'step1.csv' dsd truncover ;
length row order 8 name $32 value $200 cell $300;
row+1;
do order=1 by 1 until (cell=' ');
input cell @;
if cell=' ' then continue;
name=scan(cell,1,'=');
value=scan(cell,2,'=');
output;
end;
input;
drop cell;
run;
You could then use PROC TRANSPOSE to convert this tall structure into a wide one. But make sure you don't have the same NAME value appearing more than once in the same row.
proc transpose data=tall out=want ;
by row;
id name ;
var value;
run;
You could also add logic at some point to convert some of the values into numeric, probably based on the name.
... View more