BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
emptyhead
Calcite | Level 5

Hello everyone, I really need some advise. I have table whose column names are numbers and I can't change this setting. Now I am trying to find a solution how to union this table with others in SAS Studio. Here's what I got so far:

options msglevel=i;
options noquotelenmax;
options validvarname=ANY; /* for variables*/  

filename genFuncs FILESRVC folderpath='/department/lib_name' filename='general_functions_v2.sas';
%include genFuncs / source;

proc cas;
  %casFunctions;
  
  outCaslibName="lib_name";
  casTableName="table_union";
  tmpTableName = casTableName || "_" || rand("Integer", 111111, 999999);

  createTableString="create table lib_name." || tmpTableName ||" {options replace=true} as (

 select v.month from lib_name.normal_table v
 union all
 select t.'198'n from lib_name.uqly_table t
  )";

and I can't convince SAS, that '198'n is the month column name.
errorerror

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

I do not use CAS language, but it looks to me like you are creating a character variable that happens to contain what looks like SQL syntax.   If it is just a string then the content shouldn't matter.  So somewhere under the hood the string must have been used by some SQL process.  Perhaps that SQL process would rather that you use ANSI style double quotes around invalid names?

 

Try:

createTableString
   ="create table lib_name." || tmpTableName
  ||" {options replace=true} as ("
  ||"select v.month from lib_name.normal_table v "
  ||" union all "
  ||"select t.""198"" from lib_name.uqly_table t"
  ||")"
;

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

I do not use CAS language, but it looks to me like you are creating a character variable that happens to contain what looks like SQL syntax.   If it is just a string then the content shouldn't matter.  So somewhere under the hood the string must have been used by some SQL process.  Perhaps that SQL process would rather that you use ANSI style double quotes around invalid names?

 

Try:

createTableString
   ="create table lib_name." || tmpTableName
  ||" {options replace=true} as ("
  ||"select v.month from lib_name.normal_table v "
  ||" union all "
  ||"select t.""198"" from lib_name.uqly_table t"
  ||")"
;
emptyhead
Calcite | Level 5

Thousand thanks, it works!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 809 views
  • 1 like
  • 3 in conversation