04-30-2015 10:07 AM
I am using SAS Enterprise Guide 6.1
I am completely new to SAS and am struggling to understand some functionality. I have a background in engineering that has used MATLAB and excel in the past for data analysis. With MATLAB, it was possible to write a program that you could specify code to pull in data from different files. Does SAS allow the same thing? Hopefully I can explain via example:
I have 20 excel files with data (same column headings in each file), but I only want 3 columns of data from each file. Once the data is filtered out, I then want to query the data to see different trends and eventually output in graphs. Can I write a 'master' program to do this in SAS? In which there is a prompt to give the file path so I can pick each individual file, but then the program extracts the same columns of data each time?
Or am I thinking too much like the functionality of MATLAB?
I am also having a hard time 'importing' data and storing it in a permanent library. I created a specific library to store this data in, and when I try to save it, it doesn't show up in that library.
Again, I am a complete newbie so any 'dumbing' down you can do or pointing me to articles/instructions that are in layterms would be appreciated.
04-30-2015 10:20 AM
If you have pc sas you can use proc import, if you are only using enterprise guide you will have to use the import wizard and import each one individually.
On the first screen of the import wizard name your dataset, On the third screen you can select what columns you want to keep.
After they are all imported you can do something like this:
set file1 file2 file3 file4;
If you do not manipulate the import you can do this:
set file1(keep= var1 var2) file2(keep=var1 var2) etc;
04-30-2015 10:24 AM
You ask a lot there. You are jumping into a new application which you will need to learn from the ground up. SAS Base/Macro is the underlying tech of EG, and that is a complete language, with lots of functions and things to learn. There are SAS courses available to learn these:
Yes, SAS provides many methods of getting data into and out of its format. Again, if you are just learning then its hard to point you in a good direction. Proc import for instance is a basic tool to import data.
Yes, you can write a generic macro to read and process data, but this is an advanced topic. Start by learning the basics.
As for creating a library, libname abc "c:\temp"; should work presuming you have that directory existing and you have access. For specific issues we would need a lot more information, i.e. where is SAS located, locally/sever. If server what type, what permissions etc.
As I suggest, learn the basics, and get some help from collegues first.
04-30-2015 10:32 AM
Thanks RW9. I am taking a SAS Programming 1 and 2 course (but they don't start till May) and I'm already enjoying the 'power' that SAS has from what I've discovered just playing around in it, so I was hoping to see what I could keep learning till then. If you think I'm only overloading myself in terms of information and should just wait till the course to learn the fundamentals of the language, I might just take that approach.
04-30-2015 11:53 AM
Yes you can. There are many ways to import date in SAS/EG. Either via wizards, or via program code.
This link has a good macro to import multiple xlsx files with the same layout from 1 folder.
This forum also has lots of information about this subject if you search for it.
One additional thing I would do is create an empty table first in which you import data from the files.
Programmatically this could look like:
CREATE TABLE WORK.MYTABLE
MYFIELD1 DATE FORMAT=DDMMYYD10. ,
MYFIELD2 CHAR(90) ,
MYFIELD3 INT ,
MYFIELD4 DECIMAL FORMAT=EURO11.2