BookmarkSubscribeRSS Feed
TurnTheBacon
Fluorite | Level 6

I've used PROC IMPORT to read a semicolon-delimited CSV-file. 14 variables have been created (VAR1-VAR14). Now I wonder what kind of statements I can use to change the name and format of these variables. This is my code so far:

proc import

  file='foldername/filename.csv'

  out=&_OUTPUT. replace;

  delimiter=";";

  getnames=no;

quit;

P.S. As you can see I had to use getnames=no in the PROC IMPORT, and this cannot be changed.

Thanks for your time, and sorry for the very newbie kind of question.

1 REPLY 1
Keith
Obsidian | Level 7

My preference when importing data files is to use the import wizard first.  This rarely creates a dataset in the exact required format, however if you press F4 from within an editor window, it will recall the data step code used by the wizard.  It is then a simple matter to edit the formats and variable names to achieve your desired result.

Hope this helps.

Keith

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!

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
  • 1 reply
  • 1255 views
  • 3 likes
  • 2 in conversation