How to upload adventureworks data into sas - sas

I wonder if one of you can help me on how to upload all adventureworks database (every table) into SAS Studio?
I would like to work on adventureworks using sas base

All you need to do is create a libname reference to your database - I don't recommend creating SAS tables from the raw SQL Server data.
Example libref (using OLE DB):
libname &libref OLEDB
PROPERTIES=&sql_properties
DATASOURCE=&sql_dsn
PROVIDER=&sql_provider
SCHEMA=&sql_schema
authdomain="&sql_domain"
connection=shared;
You will need to set the relevant variables as per your environment.

It took a few years.. And the development of sasjs.. But finally, AdventureWorks for SAS is here!
Just run these two lines of code and the 5 AdventureWorks schemas will be created as different libraries under WORK:
filename mc url "https://raw.githubusercontent.com/sasjs/AdventureWorks/main/runme.sas";
%inc mc;
Just modify that file to make permanent libs / datasets. More info in the readme: https://github.com/sasjs/adventureworks

Related

Connecting Looker to SAS

Does anyone know if you can connect Looker directly to a SAS table/server? or would you use a work-around to upload the SAS data to a SQL server, then connect Looker to that?
The SAS dataset (analogous to a table) is in a proprietary, binary format. If you have SAS Access to OleDb or ODBC, I would upload the table from SAS and not bother using a SAS format.
You must have SAS Access to upload the dataset from SAS, however, otherwise you are facing how to read a SAS dataset outside of SAS issue. Let us know what you have, in terms of software, so we can help guide a solution.

Get statistics on data inserts, updates in SAS log using pass through sql connecting to Teradata

I am using SAS EG to connect to teradata to read/write destination tables. I am using pass through sql to connect to teradata. Since , this is explicit sql in SAS, i am not able to see details in logs such as record inserts to a table, updates(how many records got updated etc). Is there a way to get such information in sas logs? I know it is possible in data steps in sas but with above request i am not able to do so. Thanks for your help.
Options SASTRACE helps and you can try
options sastrace=',,,d' sastraceloc=saslog nostsuffix;;
More info what the option logs and how you can effectively use SAS Trace with Teradata connections can be found in "Troubleshooting SAS and Teradata Query Performance Problems", Jeffrey D. Bailey, 2010.
The documentation for SASTRACE option is found at:
http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a000433982.htm

Loading sas files into netezza on Aginity

I'm trying to load data with over 50 million records into Netezza using Aginity. The problem is that my data table is a sas format with extension .sas7bdat that I open on SAS Enterprise Guide. So currently I have a script that transforms the sas files into csv file that I can load into Netezza.
Is there a way that I can load these sas files directly into Netezza without having to convert it to csv? Does Aginity provide an easy method of doing this? Any help would be great, thanks!
I am not sure how can do it Netezza using Aginity but it very simple and easy in SAS enetrprise guideAs You said you have SAS eneterprise guide, please check whether you have SAS/ACCESS to Netezza. To check whether you have an SAS/ACCESS to Netezza then you can use below code in SAS enterprise guide
proc setinit; run;
If you have SAS/Access to Netezza, which probaly you may have it. To code this in SAS Enterprise guide is very easy and you can easily emulate in SAS eneterprise, by using examples shown in the link.
http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a003181092.htm
Byusing libname statement in your SAS enterprise guide and can use proc append or proc sql and also use bulk load as as shown in above link.

Open a .accdb file in sas enterprise miner

I have to perform data prediction using SAS Enterprise Miner. SAS only has an option to load a SAS table but the problem is i have a database with two tables that i have to use for the prediction. How do i get the two tables from the database into SAS Enterprise Miner.
I have not used Access or Miner in 10 years. However, I would suggest something like:
Does Access have the concept of a view? If so, then create the view in Access and then just use that.
or
Write a stand alone piece of code that pulls the tables from Access and does the join in SAS. I believe you can do this in Miner. If not, just do it in Enterprise Guide and save the table to a location you can pick it up with Miner.
or
Create a SAS view from the Access database that does the join and use that in Miner. Same as above, just save a view instead of a table -- allows you to update the Access database without having to recreate the table.
After looking into this problem I finally decided to use base SAS to read the database and extract the individual tables, save them into a SAS library, in that way they will be saved on the local drive then i could use them in Enterprise Miner.
/*Create a new library to store converted files*/
libname db 'C:\\Users\\Documents\\Data Sources';
/*import the first table from the database into the newly created library*/
proc import out = db.Table1
datatable = 'Table1'
dbms= ACCESS Replace;
database= "C:\\Users\\Documents\\Data Sources\\DBName.mdb";
usedate=yes;
scantime=no;
dbsaslabel=none;
run;
/*import the second table from the database into the newly created library*/
proc import out = db.Table2
datatable = 'Table2'
dbms= ACCESS Replace;
database= "C:\\Users\\Documents\\Data Sources\\DBName.mdb";
usedate=yes;
scantime=no;
dbsaslabel=none;
run;

SAS Enterprise Guide Libraries

I'm new to SAS and Enterprise Guide and am having problems getting my head around some basic concepts. Please could someone explain the relationship between libraries, projects, libname and libref? I am following the SAS eLearning course but when I try to link a library with the datafiles stored on my machine I keep getting the message that the library doesn't exist, even though it's right there in the Server List.
Thanks in advance
I'm taking a college level SAS course atm. From what I have learnt, libref is a name in which you associate the physical location of a group of files to SAS.
The libname statement creates a library reference (libref) for a SAS program.
In general, the basic syntax of libname is:
libname libref 'path';
For example:
libname sales 'C:\salesdata\journal\june';
In other words, for SAS to be able to read and write data from a dataset, it must know the directory or folders that contains the particular dataset. SAS calls what we humans call directory or folders as "libraries". SAS also assigns nicknames (libref) to these libraries and use the libname statement to assign the nickname to a specific folder.
For example if you want to print an existing SAS dataset located inside the "june" folder, you can do this:
libname sales 'C:\salesdata\journal\june';
proc print data = sales.revenue;
run;
SAS will print the data portion of the "revenue" dataset that is located inside the "june" folder because we have assigned sales to that folder. Hope this helps.
Particularly if you're using SAS OnDemand for your training (as I assume you are), it's unlikely you will be able to directly assign a libname to your local datafiles. You'd have to provide more information as to the location/etc. of the datafiles you're trying to access to get a better answer, but in general, if you are running SAS on a server (Enterprise Guide is the GUI you're using to connect, SAS itself is the process that actually does the frequencies/etc. and is likely on a server somewhere, in the cloud or in your company's server farm).
The key concept is that a libname must be accessible on the machine running the SAS server instance. While it is possible you might have set up your network such that the server has mapped your local machine's hard disk to a drive, this is not the case in most instances. If you're on a network and you have access to a network drive that the SAS Server also has access to, you could share information that way; but if you are running SAS in the cloud (such as for training/educational purposes with SAS OnDemand), you probably cannot access any shared drives.
Chris Hemedinger (one of the SAS folk who used to work on EG) wrote a custom task, available at this link to help copy files from local desktop to remote server. This may not be helpful with SAS OnDemand, as I think those don't permit copying files up.