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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 857 views
  • 3 likes
  • 4 in conversation