BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tom
Super User Tom
Super User
Do the names change from run to run? If not then just put the names into the program. You only have to do it once. As I said it is trivial in any modern (post 1980) editor to take a line of comma delimited names and convert it to a line of space delimited names. But if they follow that nice pattern with numeric suffixes then you do not need to type all of them because you can use variable lists to short cut it. If you do that I would rename the first one from AUT to AUT_0 so that they follow a nicer pattern. AUT_0-AUT_4 AUS_0-AUS_4 ....
If the names are in the files with the data then you will need to skip the header line when reading the data. You could try using FIRSTOBS=2 option on the INFILE statement. But test it with this program because I worry that it would only skip the header line in the first file and not those in later files.
If the names do change from run to run then you will either need to make this program much more complicated or go back to using PROC IMPORT. One nice thing about PROC IMPORT is that it will read the names from the data for you. You cannot rename variables in the current data step based on data you are reading in this step. But you could add a step to read the header line and generate a RENAME statement that you could apply later in another step, like a PROC DATASETS step for example.
biringstad
Calcite | Level 5

Thanks a lot for the help! Now the programme (finally!) works. I ended up not typing in the names, but using the var2-var2464 names, as I found it that was sufficient.

biringstad
Calcite | Level 5

Thank you for the advises. I ended up saving the dataset in a xlsx file (each table in a seperate sheet) in stead of a csv file for each table, and now it works okay, but the programme runs much slower.

 

The commands:

Proc import datafile="/folders/myfolders/WIO.xlsx"

OUT=WIO&i

DBMS=XLSX

REPLACE;

Getnames=no;

sheet=WIO&i;

RUN; 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

So, you ignored all the advice above, choose to go with the worst possible data file format, and now your program doesn't run as quickly, and likely has many issues with the data elements or the guessing of things.  You see where I am going with this...

 

CSV is text, straight import, Excel is a ZIP file with various subfolders and linked XML files, far more resource need to process the later.

biringstad
Calcite | Level 5

Your right! Maybe a stupid choice by me, but I am quite new to this. I actually thought it would be better with xlsx in stead of csv after reading your advise, but I was very wrong I guess. Now I am trying with csv and another code (see above).

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!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 19 replies
  • 21220 views
  • 2 likes
  • 6 in conversation