DATA Step, Macro, Functions and more

remove spaces from Column name

Accepted Solution Solved
Reply
Contributor
Posts: 63
Accepted Solution

remove spaces from Column name

I am using EG 4.3. I have a field heading 'Date Founded'  (it has a space in between) that contains dates in the input excel sheet. I am not supposed to touch the input excel sheet.

Is there a way to access this field in SAS EG? I tried VALIDVARNAME = ANY option to ignore spaces but my data step is not recognizing the field. The program does not give error, simply ignores calculation in the data step.


Accepted Solutions
Solution
‎05-15-2014 10:18 AM
Contributor
Posts: 53

Re: remove spaces from Column name

Posted in reply to buckeyefisher

You can access the variable by typing it like this.  This will tell sas that it is a name litteral.

'Date Founded'n

View solution in original post


All Replies
Super User
Posts: 11,343

Re: remove spaces from Column name

Posted in reply to buckeyefisher

How did you bring the data into SAS? Proc import if using the file column headers to provide variable names generally turn all spaces and special characters to underscores. I would expect the variable name to be Date_founded.

Contributor
Posts: 63

Re: remove spaces from Column name

no, it did not convert the input fields, I used proc import

proc import datafile= 'file A'

  dbms=xls out=A replace;

  sheet="xyz";

run;

Super User
Super User
Posts: 7,961

Re: remove spaces from Column name

Posted in reply to buckeyefisher

I would suspect then as you don't have getnames=yes; option, that it has been read in using default names for the columns, e.g. col1 col2 etc.

Solution
‎05-15-2014 10:18 AM
Contributor
Posts: 53

Re: remove spaces from Column name

Posted in reply to buckeyefisher

You can access the variable by typing it like this.  This will tell sas that it is a name litteral.

'Date Founded'n

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 2878 views
  • 4 likes
  • 4 in conversation