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)'
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.