I have multiple excel files where the variable length is different. Once in SAS I need to combine these files so I need to use libname excel code and read in the variable names using DBSASTYPE. Two of my variable names in excel contain symbols (+ and .) Without going into each excel file and changing the column name to exclude the symbol, is there code that will ignore those symbols?
The column in excel is ADD+, how do I code that in the DBSASTYPE lines???
LIBNAME WrkBk EXCEL "filepath/file" MIXED=YES;
DATA test1;
SET WrkBk."Subject$"n
(DBSASTYPE=(
"PACKAGE NO"='char(8)'
"SEQ"='char(8)'
"ID"='char(13)'
"NAME"='char(27)'
"ADD+"='char(27)'
));
RUN;
LIBNAME WrkBk CLEAR;
LIBNAME WrkBk EXCEL "filepath/file" MIXED=YES;
DATA test1;
SET WrkBk."Subject$"n
(DBSASTYPE=(
"PACKAGE NO"n='char(8)'
SEQ='char(8)'
ID='char(13)'
NAME='char(27)'
"ADD+"n='char(27)'
));
RUN;
LIBNAME WrkBk CLEAR;
This is how you reference non-SAS compatible column names. The rest of the code is untested.
LIBNAME WrkBk EXCEL "filepath/file" MIXED=YES;
DATA test1;
SET WrkBk."Subject$"n
(DBSASTYPE=(
"PACKAGE NO"n='char(8)'
SEQ='char(8)'
ID='char(13)'
NAME='char(27)'
"ADD+"n='char(27)'
));
RUN;
LIBNAME WrkBk CLEAR;
This is how you reference non-SAS compatible column names. The rest of the code is untested.
Thanks SASKiwi. Adding the n seems to get me past the ADD+ but I forgot to include in my orig post the var name that has the .
Adding n to this variable still produces an error saying invalid column name. Any ideas on how to resolve this?
I currently have
"AB. ADD"n='char(13)'
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.