Hi SAS Users,
I have a bunch of xls files (too many for manual adjustment). I want to read them into SAS with the types of all columns being character. And I also would like to force all the columns to have the same length, say $5000. Within each xls, I have 60 columns, so i'd prefer programming to manual change.
My SAS programming skill is intermediate I would say. And according to my knowledge, neither PROC IMPORT nor the LIBNAME excel engine can easily achieve this. Is DATA step my best option? Anybody any help? Thanks.
You'd better transform all these XLS files into CSV files . Search a tool to do that in Google .
And after that :
infile dummy filevar=fname .........
..........
input ( var1-var60) (: $200.);
Hi Xia,
Thanks. I tried to transform the XLS to CSV. But there's one column containing ";" separating names. When I save the XLS as CSV, all information after the semicolons are lost. I need to keep these semicolons for future use, so i can't dump these semicolons either. I've also tried to transfer XLS to TXT. Failed too.
That is really weird . then proc import it and transform all numeric into character .
Have just done a quick check and Excel seems to handle semicolons fine. Post your WB or sample as it should work fine.
You could use the LIBNAME engine and DBSASTYPE to achieve what you want. It takes a bit of doing (code gen);
Thank you very much, data_null_. It works well.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.