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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.