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

Hi, I uploaded a CSV file to SAS Studio, but this file has a column name with blank between two words. It causes problems when writing code referring to this variable. Is there a way to rename the variable to remove the blank so that I can refer to this column in my code? Thnak you!

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

There are at least three ways of dealing with this:

  • remove the blanks from the CSV file and re-import the data
  • run this statement to change the default behaviour (required in every submit): options validvarname = v7;
  • rename the column once imported:
data want;
  set have;
  rename 'My Column with blanks'n = My_Column_without_blanks;
run;
  •  

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

There are at least three ways of dealing with this:

  • remove the blanks from the CSV file and re-import the data
  • run this statement to change the default behaviour (required in every submit): options validvarname = v7;
  • rename the column once imported:
data want;
  set have;
  rename 'My Column with blanks'n = My_Column_without_blanks;
run;
  •  
andreas_lds
Jade | Level 19

Don't use proc import, write a data step reading the file.

Kurt_Bremser
Super User

Don't use PROC IMPORT, write the DATA step yourself. IMPORT is not needed for text files and causes unnecessary problems. See thousands of posts here.

 

As a stopgap measure, set

options validvarname=v7;

before PROC IMPORT.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1944 views
  • 3 likes
  • 4 in conversation