BookmarkSubscribeRSS Feed
Mohit21
Fluorite | Level 6

Hi Everyone,

 

I am new to SAS DI and previously working on base sas.

The problem is I have to make a job which will use external file.

However, The external file contains spaces in column names.

For example:

Student ID,Nick Name etc....

 

It does not have quotes or underscore so the DI studio reading it as two different columns.

Could someone please let me know how to deal with this.

 

Regards,

Mohit

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16
Could you please let me know the format of the external file you are trying to read and the procedure you are using to read the external file in sas
Thanks,
Jag
Mohit21
Fluorite | Level 6

It is CSV.

 

and i am importing using NEW->External FILE->DELIMITED.

SASKiwi
PROC Star

If you run your import using this statement:

options validvarname=v7;

it will convert your column names to valid SAS names including replacing spaces with underscores.

 

I recommend you use this option as it will avoid having to write SAS code like this: 'My Non-Standard Column Name'n every time you reference non-standard names. 

Patrick
Opal | Level 21

If you're new to DIS and haven't used another metadata driven ETL tool before then you will need some time to get your head around to grasp the difference between metadata and SAS code.

The DIS wizard you're using helps you to create External File Metadata. Even if the Wizard wouldn't treat blank separated column headings as two columns, you certainly wouldn't want to end-up with blank separated column names.

What you can do: Take a copy of your .csv with the headings and a few lines of data, then change the headings to the names you need as SAS variable names (compliant with SAS naming convention and your data model) and then use this file with the wizard. 

Alternatively and even easier: You know your data. Define the columns for the External File Metadata manually. The names don't need to be the same than what's in the .csv as header but should be what makes sense as SAS variable names. This being a repetitive ETL process you also don't want the wizard to define the column attributes like the length. You need in any case to amend what the wizard creates here as this is only appropriate for the .csv you currently have. Next day's .csv could contain longer strings.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 875 views
  • 0 likes
  • 4 in conversation