BookmarkSubscribeRSS Feed
PQK
Calcite | Level 5 PQK
Calcite | Level 5
Dear Forum,

I can accurately read CSV file data using EG4.3 and IMPORT (File > Import Data) even though the file contains a first line of column names with embedded blanks, dashes (-), parentheses and periods.

However, I am learning how to program in SAS and would like to replace this step with code. I can create working code with DATA, INFILE, INPUT statements and so forth using standard column names.

The problem is how to get SAS to read column names when the column names include spaces, parentheses etc.

If I borrow the 'column name'n convention EG4.3 generates in the INPUT statement from the IMPORT Wizard code, I either get a tableview with ??? in each cell (in the case of EG4.3) or I get the error "The name is not a valid SAS name." if I run my code in SAS9.2 using the 'column name'n convention.

Even if I cut and paste the entire EG4.3 code from the IMPORT step into a seperate code program and run it in a seperate project, I still get a tableview with ??? in each cell.

What I'm I doing wrong?
2 REPLIES 2
ChrisHemedinger
Community Manager
You might need to set this option:

options validvarname=any;

EG sets it by default, but if you are running in SAS Display Manager or batch, it's not the default setting.

http://support.sas.com/kb/14/661.html

Chris
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
PQK
Calcite | Level 5 PQK
Calcite | Level 5
Chris,

Thank you for your reply to my post.

It turned out that the problem with ??? in each cell of my tableview was due to the length and format of various numeric/character variables. After conducting a careful trial and error analysis of each variable I was able to narrow down the issue to a view problem variables.

Your suggestion in regards to changing the VALIDVARNAME option worked perfectly for base SAS (9.2). Although the default in EG4.3 is already set to VALIDVARNAME=ANY, the option in Base SAS was set to V7. After changing this option (and my changes to the length and format mentioned above), both Base SAS and EG4.3 were able to produce the dataset from code.

Best Regards,

PQK

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 3854 views
  • 0 likes
  • 2 in conversation