I would like to use PROC IMPORT and force all variables to character. Since I am reading CSV files, I cannot use the MIXED= option.The attributes of the files are unknown and I am hoping that I will not have to build something to parse them individually.
I have never seen such an option.
How hard do you want to work to import the file(s)? Are you willing to accept that all variables are the same length? If so then read the first line into a macro variable that you can use as the list of variable names.
data _null_;
infile tmpfile1 obs=1 ;
input ;
call symputx('varlist',translate(_infile_,' ',','));
run;
data want ;
infile tmpfile1 dsd firstobs=2 truncover ;
length &varlist $200 ;
input &varlist ;
run;
Doc Arthuer,
I am afraid that is hard for proc import . As Tom mentioned There is not an option to control it. The only thing I can think is about modify that csv file and import it.
data _null_; infile 'c:\temp\x.csv' ; file 'c:\temp\temp.csv'; input; _infile_=tranwrd(cats(_infile_,'09'x),',',cats('09'x,',')); put _infile_; run; proc import datafile='c:\temp\temp.csv' out=x dbms=csv replace;run;
Ksharp
Message was edited by: xia keshan
That was what I thought, but was hoping that I had missed something. Brute force it will be.
Thanks
Not exactly main stream. Might be a good TRANSPOSE example;
NULL,
Good to know something new, but that is unfit to large csv file ( 1 G ) or have lots of variables . that will reduce performance very much.
Ksharp
You’re ability to grasp the obvious is astonishing.:smileyplain:
Thanks Data _NULL_. I wish that I could give you a "correct answer" for your 'sincere' praise
NULL,
Don't be offended ! Yours is good if csv file is small .
Regards
Xia Keshan
from China
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.