BookmarkSubscribeRSS Feed
BKP
Calcite | Level 5 BKP
Calcite | Level 5

Hello, I am a SAS novice and learning SAS on my own. Here is what I'm trying to do:

 

I have SAS installed on UNIX. I use MS ACCESS to produce GUI based reports. I have few large files in SAS/UNIX. Is it possible to run query in SAS/UNIX files and produce report in MS ACCESS? I don’t want to import huge files from SAS/UNIX to MS ACCESS.

5 REPLIES 5
ChrisHemedinger
Community Manager

If you have a SAS/SHARE server set up, you can use the SAS ODBC driver:

 

http://support.sas.com/software/products/odbc/

 

If you have SAS Integration Technologies (for use with SAS Enterprise Guide, for example), you can use the SAS IOM OLE DB provider.  You'll have to specify a connection string that includes your SAS Workspace host, port, and credentials.

 

Be sure to apply proper filters when you access (SQL or WHERE clause) so that you don't pull that huge data into your MS Access session.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
BKP
Calcite | Level 5 BKP
Calcite | Level 5

Is it possible to run query against SAS files stored on UNIX without importing files to MS Access?

SASKiwi
PROC Star

One approach might be to do all of your big volume data processing in SAS, producing summary SAS tables that you then export to Access. If you have SAS/ACCESS Interface to PC Files you can export to MS Access instead of importing from it. 

rogerjdeangelis
Barite | Level 11
You should be able to do this with the IML interface to R

You will need a prebult access database to write into.
Microsoft changes the structure of access so R works better
if you supply the access database.

You can find a sample access databases at
C:\Program Files\sashome\SASFoundation\9.4\access\sasmisc


* I have 64bit SAS 9.4M2 on Windows and 64 bit Office
* there are options for all combinations of 32 and 64bit R or/and Office
* Should work almost everywhere (Windows/Unicies/Mac OS but not Z/OS or VMS)



HAVE  Subset of SASHEL.CLASS
============================

SASHELP.CLASS

Up to 40 obs SD1.CLASS total obs=19

Obs    NAME       AGE    HEIGHT    WEIGHT

  1    Alfred      14     69.0      112.5
  2    Alice       13     56.5       84.0
  3    Barbara     13     65.3       98.0
  4    Carol       14     62.8      102.5
  5    Henry       14     63.5      102.5
  6    James       12     57.3       83.0
  7    Jane        12     59.8       84.5

WANT ( Coefficient and residual reports in MS Access)
===============================================

COEFFICIENTS

             names.cof.         cof
(Intercept) (Intercept) -141.223763
AGE                 AGE    1.278393
HEIGHT           HEIGHT    3.597027

RESIDUALS

      NAME SEX AGE HEIGHT WEIGHT        RESID       FIT
1   Alfred   M  14   69.0  112.5 -12.36856100 124.86856
2    Alice   F  13   56.5   84.0   5.37266290  78.62734
3  Barbara   F  13   65.3   98.0 -12.28117040 110.28117
4    Carol   F  14   62.8  102.5  -0.06699663 102.56700
5    Henry   M  14   63.5  102.5  -2.58491519 105.08492
6    James   M  12   57.3   83.0   2.77343421  80.22657
7     Jane   F  12   59.8   84.5  -4.71913207  89.21913
8    Janet   F  15   62.5  112.5   9.73371881 102.76628
9  Jeffrey   M  13   62.5   84.0 -16.20949616 100.20950
10    John   M  12   59.0   99.5  13.15848914  86.34151
11   Joyce   F  11   51.3   50.5  -6.86601421  57.36601
12    Judy   F  14   64.3   90.0 -17.96253640 107.96254
13  Louise   F  12   56.3   77.0   0.37046072  76.62954
14    Mary   F  15   66.5  112.0  -5.15438724 117.15439
15  Philip   M  16   72.0  150.0  11.78357444 138.21643
16  Robert   M  12   64.8  128.0  20.79573537 107.20426
17  Ronald   M  15   67.0  133.0  14.04709951 118.95290
18  Thomas   M  11   57.5   85.0   5.33242142  79.66758
19 William   M  15   66.5  112.0  -5.15438724 117.15439


SOLUTION

options validvarname=upcase;
libname sd1 "d:/sd1";
data sd1.class;
  set sashelp.class(keep=name age weight height);
run;quit;

%utl_submit_r64('
library(haven);
library(RODBC);
library(Zelig);
myDB<-odbcDriverConnect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=d:/mdb/demo.accdb");
class<-read_sas("d:/sd1/class.sas7bdat");
z.o1 <- aov(WEIGHT ~ AGE + HEIGHT,data=class);
cof<-z.o1$coefficients;
coef=data.frame(names(cof),cof);
coef;
RESID<-z.o1$residuals;
FIT<-z.o1$fitted.values;
residual<-cbind(class,RESID,FIT);
residual;
sqlSave(myDB,residual,rownames=FALSE);
sqlSave(myDB,coef,rownames=FALSE);
close(myDB);
');

ChrisHemedinger
Community Manager

You can apply a filter as a query on the "command" you send via OLE DB.  This SAS Note has some VB Script examples.  These might be overkill for what you're looking for.

 

It sounds like you need to access SAS as a database via MS Access.  ODBC and OLE DB are standard approaches from MS Access, if you have a running SAS instance (like SAS/Share or a SAS Workspace) that you can connect to.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 5 replies
  • 1252 views
  • 1 like
  • 4 in conversation