BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sassy7
Obsidian | Level 7

I am writing a job for selecting some observations from the AUDIT data source of SAS VA: the data source contains three variables that have spaces in their name (the variables are: User ID, Time Stamp and Remote Address). With SAS Studio, I was able to write and execute a program that creates a smaller dataset using data step (or proc sql), but I am having issue using the same code in SAS DI.

the code is the following:


libname xyz cas caslib=XYZ datalimit=all;


data work.audit_select;
set xyz.audit;
where Application="reports" and
URI contains ".report" and
'User ID'n not contains "sas.";
if intck ('day', input(substr('Time Stamp'n,1,10), yymmdd10.), today()) < 3 then output;

run;

 

the error message I receive is 

ERROR: The name Time Stamp is not a valid SAS name.

 



Any suggestion how to handle spaces in names in SAS DI studio?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Why would it complain about 'Time Stamp'n and not 'User ID'n.

 

If you have to working with non-standard variable names then make sure the VALIDVARNAME option is set to ANY.

options validvarname=any;

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

Why would it complain about 'Time Stamp'n and not 'User ID'n.

 

If you have to working with non-standard variable names then make sure the VALIDVARNAME option is set to ANY.

options validvarname=any;
sassy7
Obsidian | Level 7
Thanks it worked!
acordes
Rhodochrosite | Level 12

working with cas I have the same issue now and then.

The way to solve it is placing the code into a datastep.runcode in order to rename the variable.

It doesn't make sense to me WHY it works but it does.

Every time I have this error message (normally related to variable names longer than 32) I can fix it using this trick.

In SAS Studio use the caslib menu, open the caslib, open the table and drag&drop the variable name into the code.

During the import sometimes blank characters or other strange ones are woven into the variable name.

 

proc cas;
action table.tableexists result=rc/
name="audit" caslib="xyz";
run; 
if rc.exists then dataStep.runCode result=r status=rc / code=
'data public.temp;
	set xyz.audit;
rename "time stamp"n=time_stamp; 
run;';

data work.audit_select;
set public.temp;
where Application="reports" and
URI contains ".report" and
'User ID'n not contains "sas.";
if intck ('day', input(substr(Time_Stamp,1,10), yymmdd10.), today()) < 3 then output;
run;


 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1980 views
  • 0 likes
  • 3 in conversation