Sas add in for excel

The SAS ADD-IN for Microsoft Office adds a

  • SAS menu to the menu bar
  • SAS Analysis toolbar
  • SAS Data Analysis toolbar (Excel only).

SAS Menu for Microsoft Excel

The SAS menu in Microsoft Excel provides access to the functionality of the SAS Add-In for Microsoft Office, including the following:

  • Ability to run stored processes or SAS task
  • Tools to work with a SAS data source
  • Options for the SAS Add-In
  • Ability to specify the server
  • The style manager to customize the appearance of results returned to Microsoft.

style manager to customize

SAS Menu for Microsoft Word

The SAS menu in Microsoft Word provides access to the functionality of the SAS Add-In for Microsoft Office, including the following:

  • Ability to run stored processes or SAS task
  • Options for the SAS Add-In
  • Ability to specify the server
  • The style manager to customize the appearance of results returned to Microsoft

SAS Menu for Microsoft Word

SAS Add-In Options – Excel

The SAS Add-In for Microsoft Office options for Excel is specified by selecting SAS Ð Options….

SAS Add-In Options – Excel

SAS Add-In Options– Word

The SAS Add-In for Microsoft Office options for Word are specified by selecting SAS Ð Options….

SAS Analysis Tools Toolbar

The SAS Analysis Tools toolbar provides access to some of the same options as the SAS menu.
Some of the tasks that can be performed include the following:

  • Changing the active data source
  • Showing labels in the first row
  • Refreshing the results
  • Viewing the data
  • Browsing SAS programs
  • Exporting results to MS Word
  • Accessing your SAS Favorites.

SAS Data Analysis Toolbar

The SAS Data Analysis toolbar provides access to options for working with SAS data.
The tasks that can be performed include the following:

  • Opening a SAS data source
  • Navigating through the data
  • Using a filter
  • Sorting the

The SAS Data Analysis toolbar is not available in Microsoft Word.

MindMajix Youtube Channel

Filtering SAS Data in Microsoft Excel

The SAS Add-In for Microsoft Office can filter SAS data before bringing it into Excel.

Filtering SAS Data in Microsoft Excel

Selecting opens an Expression Editor window for creating more advanced expressions.

expression editor

Sorting SAS Data in Microsoft Excel

The SAS Add-In for Microsoft Office can also sort SAS data before bringing it into Excel.

Sorting SAS Data in Microsoft Excel

Restricting SAS Columns in Microsoft Excel

The SAS Add-In for Microsoft Office provides a mechanism to select which columns are displayed.

Restricting SAS Columns in Microsoft Excel

Built-In SAS Tasks

The SAS Add-In for Microsoft Office provides access to most of the same tasks found in the SAS Enterprise Guide.
These tasks are broken down into the following categories:

  • ANOVA
  • Basic Analysis
  • Capability
  • Control Charts
  • Data
  • Describe
  • Graph
  • Multivariate
  • Pareto
  • Regression
  • Survival Analysis
  • Time Series

Using the SAS Add-In for Microsoft Office

For this demonstration, you will

  • Set the SAS Add-In for Microsoft Office options
  • Run stored processes
  • Access a SAS data source
  • Show filtering and sorting
  • Run a built-in SAS task.

SAS Add-In for Microsoft Office

  1. Invoke Microsoft Excel by selecting Start Ð All Programs Ð Microsoft Office Ð Microsoft Excel.
  2. Select SAS Ð Options from the pull-down menu.
  3. The SAS Add-In displays an information window while it connects to the SAS Metadata Server.

sas add in

4. If prompted, enter the user name and password provided by your instructor.

server login

Select ok button

5. The Options window opens with the Data tab selected.

sas add-in options window

This tab is where you can set the number of observations to display as each “page” of data is requested from the SAS Server.
6. Select the Results tab.

sas add-in results tab

This tab can be used to set how the results are returned, HTML or CSV.
Using this tab you can also select whether or not the SAS log should be displayed.
7. Select the Graph tab.

Graph tab

This tab is where you can select the image format for graph. The valid values are as follows:

  • ActiveX
  • ActiveX image
  • GIF
  • JPEG
  • PNG

8. Select the Tasks tab.

Select the Tasks tab

9. Change the default SAS server to use SASMain instead of Local (the default).

default sas server

10. Select the Stored Processes tab.

stored processed tab

11. Select to close the Options window and save the changes.

Run a Stored Process Using the SAS Add-In for Microsoft Office

12. Select SAS Ð Browse SAS Programs from the pull-down menus (or select on the toolbar).
a. Expand the Stored Processes tree (select Stored Processes Ð Samples) and select Stored Processes.
b. Select Sample: Frequency Analysis of Municipalities.

browse sas programs

Sample stored processes are automatically provided with the Web Infrastructure Kit. These samples can be run to verify that the system is configured properly and to sample the capabilities of stored processes.
c. Select run

add-in window

The program results are streamed back to an Excel worksheet which is given the name of the stored process.

excel worksheet

The results are displayed in a read-only worksheet, so the values cannot be updated. To edit the worksheet, select Tools Ð Protection Ð Unprotect Sheet….
If you always want the sheet unprotected, you can specify that by selecting SAS ÐOptions and then deselecting the Protect data worksheet check box on the Data tab.

Send Results from Excel to Word

13. Select SAS Ð Send to Microsoft Word (or select from the toolbar).

excel to word

When an analysis is selected to be sent to Word, the stored process runs again to incorporate any changes that were made to the data source before the analysis is seen. After the output is available in the Word document, the document can be edited and new text is added using the functionality of Microsoft Word.

14. You can also run stored processes directly from Microsoft Select SAS ÐBrowse SAS Programs.
a. If prompted, enter the username and password provided by your instructor.

metadata server login window

b. Navigate to the stored process created earlier by expanding the tree (select Stored Processes ÐTraining).
c. Select Orion Customer List.

browse sas programs

Select run
15. Because this stored process has a parameter, you are prompted to enter a Type 10 and selectrun

orion customer list

details in word document

The output from the Stored Process is streamed back to the cursor position in the current document unless the Insert results into current document option is deselected on the Results tab of the SAS Options in Word.
16. Close Word by selecting File Ð Exit (do not save the changes).

Managing Favorites

17. Back in Excel, select SAS Ð My SAS Favorites Ð Manage Favorites….
18. Add a stored process sample to My SAS Favourites.
        a. Expand Stored Processes and Samples, select Stored Processes.
        b. Right-click Sample: Frequency Analysis of Municipalities.
        c. Select Add to Favorites.

managing favorites

19. Add another stored process to My SAS Favourites.
        a. Select Training.
        b. Right-click Orion Customer List.
        c. Select Add to Favorites.

add to favorites

20. Add a Task to My SAS Favourites.
        a. Expand SAS Tasks and Describe.
        b. Right-click One-Way Frequencies.
        c. Select Add to Favorites.

sas tasks

21. Close the Manage Favorites window by selecting close button
22. Select My SAS Favorites from the toolbar, and notice that the newly added favorites are on the list:

favorites window

23. Organize favorites by selecting Manage Favorites….
24. Select the New Favorites Folder icon (sample icon) and type Samples as the name of the new folder

create or open new window

25. Drag the Sample: Frequency Analysis of Municipalities and drop it into the new folder Samples.
26. Select to close the Manage Favorites window.

Add SAS Data to Excel

The SAS Add-In for Microsoft Office allows Excel to access SAS data from a server or your local machine and add it to an Excel workbook.
27. Select SAS Ð Open SAS Data Source from the pull-down menus (or select from the toolbar).
a. Select Servers from the Shortcut Bar, then choose SASMain.

open sas data source

Select open button
b. Select Orion Star Gold Library, then choose 

open sas data source 1

c. Select CUSTOMER_DIM, then choose open button 2

CUSTOMER_DIM

If you cannot read the entire name of a table, use the View Mode icon on the toolbar to change the view to Detail or List.
The first “page” of data is streamed back to an Excel worksheet which is given the name of the library reference and table name.

view mode icon

Working with Data in Excel Using the SAS Add-In

Excel limits the number of rows available in a worksheet to 65,536 and the columns to 256.

By adding data sources to your workbook via SAS, you can open data sources that are larger than 65,536 rows or have more than 256 columns or both. The SAS Add-In has options to set a number of rows to view and provides a mechanism to select only the columns you want to see.

The SAS Data Analysis toolbar can be used to navigate through the data, apply a filter, sort the data, and restrict which columns to display.

Working with Data in Excel

28. Click on the range of records (1-5000) from the SAS Data Analysis toolbar to change the starting point (or select SAS Ð Navigate SAS Data Source Ð Go To Record).

index window

29. Type in a value of 4000, then click on  ok button

values in worksheet

The worksheet now displays records 4000-8999.
The default number of rows that is displayed can be changed from the Data tab of the SAS Options window in Excel.

sas add-in options

The arrow tools on the SAS Data Analysis toolbar allows scrolling through the data. The arrows with the bars next to them take you all the way to the beginning or end of the data. The single arrows scrolls one “page” of data at a time (5,000 rows by default).
30. Select arrow1(or SAS Ð Navigate SAS Data Source Ð Go to End).
31. Select arrow2(or SAS Ð Navigate SAS Data Source Ð Go to  Start).

SAS Data Can Be Subset in Excel by Using a Filter

32. Filter the data so that only United States customers who are also Orion Star Group Members are displayed.
a. Select the SAS Data Analysis toolbar (or select SAS Ð Filter SAS Data Source).
b. Select in the first box and select the desired column name, Customer Country.

more data options window

c. Select  in the second box and specify the filter criteria, Is equal to.

more data options window1

d. Select  in the third box and select the desired value, US.

selecting the country

e. Select ok button
f. Select  in the last box and specify a condition (AND) in order to create combination filter.

filter the output

g. Complete the new line of the filter for Customer  Group  Name Is equal to Orion  Club  Gold  members.

h. Select validate to validate the filter.

sas add-in

i. Select ok button to close validation window.
j. Select advanced edit1 to open the Advanced Expression Editor window.

advanced expression editor1

The Advanced Expression Editor is very similar to the editor in SAS ETL Studio.
k. Select ok button to close the Advanced Expression Editor window and apply the specified filter to the data.
l. Select OK to close the More Data Options window and apply the specified filter to the data.
The expression is evaluated on the Workspace Server and the first “page” of filtered data is returned to Excel.

full data in excel sheet

 to  to indicate that a filter is applied.

SAS Data Can Be Sorted in Excel by Specifying a Sort Criteria

33. Sort the data by the customer’s first and last names.
a. Select sorting icon on the SAS Data Analysis toolbar, or select SAS Ð Sort SAS Data Source.
b. Select icon1 in the box and select Customer Last Name.

Specifying a Sort Criteria

c. To sort by first name within last name, select in the second box and select Customer First  Name.

using preferences

d. Select ok button4 to close the More Data Options window and sort the data.
The data is sorted on the Workspace Server and the first “page” of sorted data is returned to Excel.

desired output

Built-In SAS Tasks are Helpful in Analyzing Data

34. Select SAS Ð Browse SAS Programs.
a. Expand SAS Tasks and select Describe Ð One-Way Frequencies.

browse sas programs1

b. Select run button.The One-Way Frequencies Experimental Wizard opens with a list of the available columns.

task roles

c. Select Customer_Age_Group and Customer_Gender as Analysis variables.

one way frequencies

d. Select Statistics in the list on the left, then select Frequencies and percentages.

Frequencies and percentages

e. Select Plots in the list on the left, then select Horizontal.

selecting the horizontal

Select run button 2
The frequency task runs and displays the results in the worksheet that is given the name of the SAS task.

requency task

35. Close Excel by selecting File Ð Exit (do not save the changes).

Содержание

  1. Blogs
  2. Using Microsoft Excel functions in SAS
  3. Excel functions as SAS user-defined functions
  4. Examples of Microsoft Excel functions usage in SAS
  5. ODD function
  6. EVEN function
  7. FACTDOUBLE function
  8. PRODUCT function
  9. MULTINOMIAL function
  10. Other Microsoft Excel functions available in SAS
  11. Additional Resources on SAS user-defined functions
  12. Your thoughts?
  13. About Author
  14. 29 Comments
  15. Leave A Reply Cancel Reply

Blogs

Using Microsoft Excel functions in SAS

You might have heard about SAS — Microsoft partnership announced in June 2020 that officially joined the powers of SAS analytics with Microsoft’s cloud technology to further advance Artificial Intelligence (AI).

This partnership did not just happen out of nowhere. SAS has a long and deep history of integrating with Microsoft technologies. Examples include:

  • XLSX Access Engine for transparent access to Microsoft Excel workbooks residing on UNIX or Microsoft Windows;
  • SAS Add-In for Microsoft Office, which extends Microsoft Office to use the power of SAS data access, analysis, and reporting directly from Microsoft Outlook, Excel, Word, and PowerPoint;
  • The ability to use SAS with Microsoft 365 (OneDrive, Teams, and SharePoint).

In this post we will look at a lesser known, but quite useful feature in SAS that allows SAS users to bring many Microsoft Excel functions right to their SAS programs. I hope that many SAS users (not just MS Excel aficionados) will love to discover this functionality within SAS.

Excel functions as SAS user-defined functions

SAS has a wide variety of built-in functions, however there are still many Microsoft Excel functions that are not intrinsically implemented in SAS. Luckily, many of them are made available in SAS via PROC FCMP as user-defined functions (see section PROC FCMP and Microsoft Excel). These functions are predefined for you and their definitions are stored in the SASHELP.SLKWXL data table provided with your SAS installation. You can generate a list of these functions by running the following code:

You can also capture the list of available Excel functions in a SAS data table using ODS OUTPUT with CODELIST= option:

From this data table you can produce a nice looking HTML report listing all these functions:

When you run this code, you should get the following list of Excel functions along with their SAS equivalents:

List of Excel functions available in SAS (via SASHELP.SLKWXL)

Obs Excel Function SAS Function Arguments
1 even even_slk ( x )
2 odd odd_slk ( x )
3 factdouble factdouble_slk ( x )
4 product product_slk ( nums )
5 multinomial multinomial_slk ( nums )
6 floor floor_slk ( n, sg )
7 datdif datdif4_slk ( start, end ) **** NOTE: a subset of datdif for DAYS only
8 amorlinc amorlinc_slk ( cost, datep, fperiod, salvage, period, rate, basis )
9 amordegrc amordegrc_slk ( cost, datep, fperiod, salvage, period, rate, basis )
10 disc disc_slk ( settlement, maturity, pr, redemp, basis )
11 tbilleq tbilleq_slk ( settlement, maturity, discount )
12 tbillprice tbillprice_slk ( settlement, maturity, discount )
13 tbillyield tbillyield_slk ( settlement, maturity, par )
14 dollarde dollarde_slk ( fdollar, frac )
15 dollarfr dollarfr_slk ( ddollar, frac )
16 effect effect_slk ( nominal_rate, npery )
17 coupnum coupnum_slk ( settlement, maturity, freq, basis )
18 coupncd coupncd_slk ( settlement, maturity, freq, basis )
19 coupdaysnc coupdaysnc_slk ( settlement, maturity, freq, basis )
20 couppcd couppcd_slk ( settlement, maturity, freq, basis )
21 coupdays coupdays_slk ( settlement, maturity, freq, basis )
22 db db_slk ( cost, salvage, life, period, month )
23 yield yield_slk ( settlement, maturity, rate, pr, redemp, freq, basis )
24 yielddisc yielddisc_slk ( settlement, maturity, pr, redemp, basis )
25 coupdaybs coupdaybs_slk ( settlement, maturity, freq, basis )
26 oddfprice oddfprice_slk ( settlement, maturity, issue, fcoupon, rate, yield, redemp, freq, basis )
27 oddfyield oddfyield_slk ( settlement, maturity, issue, fcoupon, rate, pr, redemp, freq, basis )
28 oddlyield oddlyield_slk ( settlement, maturity, linterest, rate, pr, redemp, freq, basis )
29 oddlprice oddlprice_slk ( settlement, maturity, linterest, rate, yield, redemp, freq, basis )
30 price price_slk ( settlement, maturity, rate, yield, redemp, freq, basis )
31 pricedisc pricedisc_slk ( settlement, maturity, discount, redemp, basis )
32 pricemat pricemat_slk ( settlement, maturity, issue, rate, yld, basis )
33 yieldmat yieldmat_slk ( settlement, maturity, issue, rate, pr, basis )
34 received received_slk ( settlement, maturity, investment, discount, basis )
35 accrint accrint_slk ( issue, finterest, settlement, rate, par, freq, basis )
36 accrintm accrintm_slk ( issue, maturity, rate, par, basis )
37 duration duration_slk ( settlement, maturity, coupon, yld, freq, basis )
38 mduration mduration_slk ( settlement, maturity, coupon, yld, freq, basis )
39 avedev avedev_slk ( data )
40 devsq devsq_slk ( data )
41 varp varp_slk ( data )

NOTE: Excel functions that are made available in SAS are named from their Excel parent functions, suffixing them with _SLK to distinguish them from their Excel incarnations, as well as from native SAS functions.

Examples of Microsoft Excel functions usage in SAS

In order to use any of these Excel functions in your SAS code, all you need to do is to specify the functions definition data table in the CMPLIB= option:

Let’s consider several examples.

ODD function

This function returns number rounded up to the nearest odd integer:

SAS log:
odd( 5.9 ) = 7

EVEN function

This function returns number rounded up to the nearest even integer:

SAS log:
even( 6.4 ) = 8

FACTDOUBLE function

This function returns the double factorial of a number. If number is not an integer, it is truncated.
Double factorial (or semifactorial) of a number n, denoted by n!!, is the product of all the integers from 1 up to n that have the same parity as n.
For even n, the double factorial is n!!=n(n-2)(n-4)…(4)(2), and for odd n, the double factorial is n!! = n(n-2)(n-4)…(3)(1).

Here is a SAS code example using the factdouble() Excel function:

It will produce the following SAS log:
6 !! = 48
7 !! = 105

Indeed, 6!! = 2 x 4 x 6 = 48 and 7!! = 1 x 3 x 5 x 7 = 105.

PRODUCT function

This function multiplies all elements of SAS numeric array given as its argument and returns the product:

SAS log:
x = ( 5 7 1 2 2 )
product(x) = 140

Indeed 5 x 7 x 1 x 2 x 2 = 140.

MULTINOMIAL function

This function returns the ratio of the factorial of a sum of values to the product of factorials:

In SAS, the argument to this function is specified as numeric array name:

SAS log:
a = ( 1 3 2 )
multinomial(a) = 60

Indeed (1+3+2)! : (1! x 3! x 2!) = 720 : 12 = 60.

Other Microsoft Excel functions available in SAS

You can explore other Excel functions available in SAS via SASHELP.SLKWXL user-defined functions by cross-referencing them with the corresponding Microsoft Excel functions documentation (alphabetical or by categories). As you can see in the above List of Excel functions available in SAS, besides mathematical and statistical functions exemplified in the previous section, there are also many Excel financial functions related to securities trading that are made available in SAS.

Additional Resources on SAS user-defined functions

Your thoughts?

Have you found this blog post useful? Please share your use cases, thoughts and feedback in the comments below.

Leonid Batkhan is a long-time SAS consultant and blogger. Currently, he is a Lead Applications Developer at F.N.B. Corporation. He holds a Ph.D. in Computer Science and Automatic Control Systems and has been a SAS user for more than 25 years. From 1995 to 2021 he worked as a Data Management and Business Intelligence consultant at SAS Institute. During his career, Leonid has successfully implemented dozens of SAS applications and projects in various industries. All posts by Leonid Batkhan >>>

Perfect, I have a client new to SAS, but very adept at Excel. I often find that it helps if I can talk to them in Excel, but this will help be our Rosetta Stone 🙂

Thank you, Andrea, great observation. And this bridge works both ways: it can be Rosetta Stone for «native Excel speakers» to learn SAS, as well as for «native SAS speakers» to learn Excel 😉

Thanks Leonid, this is very helpful. I hope you can present this as a conference paper or perhaps a Super Demo once we start having conferences in person again.

Sounds like a good idea. Thank you, Bruce, for this very constructive exchange.

That would be excellent. I do think these functions have value and am very glad you’ve publicized them.

I do have one more question. I’m doing a little internal writeup on these, and included a summary of each function from https://support.microsoft.com/en-us/office/excel-functions-alphabetical-b3944572-255d-4efb-bb96-c6d90033e188#bm25. 40 of the 41 functions are described there, but I can’t find DATDIF4 there or by googling for it. That page does have DATDIF. DATDIF4 is definitely the name in SASHELP.

Thank you, Bruce. Indeed, there is DATDIF() function in MS Excel, but DATDIF4_SLK() function in SAS. The original DATDIF() function has 3 arguments (3rd argument is unit — DAY, MONTH, YEAR. ), however, DATDIF4_SLK has only 2 arguments as it implements a subset of DATDIF() for DAYS only. I made corresponding correction in the table and added NOTE to it.

Thanks Leonid. Too bad they deleted it. This is a nice feature that is not well known at all.

As far as I remember that disappeared post was just a list of Excel functions available in SAS. Now, with this blog post the same listing (augmented with the corresponding SAS names and arguments) is included here, so maybe the doc’s link needs to be updated to point to this blog post.

Leonid:
Hi, thanks for clarifying this. Just one followup question. You mention above that:
Luckily, many of them are made available in SAS via PROC FCMP as user-defined functions (see section PROC FCMP and Microsoft Excel).

I clicked the PROC FCMP link and in the section PROC FCMP and Microsoft Excel there’s a link for: You can view these functions at Excel functions in SAS.
That link took me to the SAS Communities home page. Various searches there didn’t yield anything obvious. Do you know what it’s trying to point me to?

Hi Bruce,
I think it used to be a post on the SAS Communities that listed all the MS Excel functions implemented in SAS, but it was deleted at some point. I will let SAS documentation specialists know so they take care of that broken link. Thank you for catching that.
Best regards,
Leonid

It has been corrected in the SAS documentation. Now, the PROC FCMP documentation links to the table of Excel functions available in SAS in THIS blog post 🙂 .

Hi Leonid. It’s been a while since we sat next to each other on a flight back from a conference.

This feature is really interesting and I’d not heard of it. Two questions
1. Are we calling the actual Excel functions, or SAS re-writes of them?

2. If the former, I see that a lot of the financial functions deal with dates and wondered how are they being handled. If I pass in SAS dates, are they being translated to account for January 1, 1960 being 0 in SAS and January 1, 1900 being 1 in Excel? I realize that a lot (all?) of them involve a range of dates so if the number of dates is the same whatever the «0» date is, it might not matter. But it might in some cases.

Hi Bruce, great memories!

These are not «actual» Excel functions, but rather SAS incarnations of them. SAS implemented (re-wrote) them as user-defined functions using PROC FCMP. Therefore, one can expect dates being treated as SAS date values. Hope this clarifies it for you.

Best regards,
Leonid

Very interesting, some useful gems here. I’m particularly surprised there isn’t a native «product» function in SAS; if there were I think it would see use.

The requirement to specify the arguments as an array, as for product_slk is a downside since it means the function can’t be used in contexts where arrays are unavailable (say, PROC SQL).

Thank you, Matthew, for your feedback. I consider your first sentence as a vote for implementing product function as a native SAS function.
In PROC SQL you don’t need an array and therefore product function to multiply columns, you can do that by listing them separated with ‘*’ (multiplication operator): COL1 * COL2 * COL3 . * COLn.

Ok: neat, handy and cool, BUT! Why does SAS not implement its own functions instead if SAS believes they are so important?

Hi Daniel, thank you for your comment. SAS is a customer-centric organization. If you as a SAS user believe these functions need be natively implemented, say it. Meanwhile, SAS made it available to the SAS user community as user-defined functions.

Hi Leonid, do you know if I can compress the size of a file that gets exported using the XLSX engine? Thank you in advance,

Hi, Cristina! Here is an example of how you can compress (zip) your .xlsx file (or any file) on Windows:

Is that what you were looking for?

Thank you Leonid! I sincerely appreciate this!

You are welcome, Cristina! I am glad I was able to help.

This is yet another hidden SAS gem that I would not have stumbled upon. Thanks for revealing this to us Leonid!

You are welcome, Jerry! And thank you for your feedback.

Amazing! This is new to me and will be useful. Thank you for sharing new tips.

You are welcome, Tatiana! I learned it myself recently 🙂 «Век живи – век учись» (literally «a century live, a century learn»).

Very useful info. Clear and informative.

Comments also informative and appreciated

Thanks again Leonid!

You are very welcome, Deborah! Thank you for your comment.

Thanks for sharing this!! Didn’t know about these included excel functions. This could be very useful.

Thank you, Bill, for your kind feedback. Would love to hear from people if they actually use this.

Leave A Reply Cancel Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Источник

I came across the same «need» and after some research here and there, I found a nice and easy way with R and the latest version of RStudio (as per 2020 June date — the FREE one). Using it, you can open various formats of files and RStudio generates for you the R script it ran behind. You can use this as a starting point, in order to have the .sas7bdat file opened, and then do the conversion step.

Steps to follow in order to import the file using the RStudio «visual» way: Evironment tab -> Import Dataset -> From SAS...

It will ask you to import the haven library. After the installation you will have a tab with the preview of the data within the file and also the R script ran behind which will look like this:

library(haven)
aux <- read_sas("//PATH_ON_YOUR_MACHINE_TO_FILE/actual_file.sas7bdat", NULL)
View(aux)

Notice the NULL there, it has the purpose of converting empty strings to NULL.

But wait, we also need to convert it to a .csv file in order to have the final job done. For this you simply add below those lines from above the following:

write.csv(aux, "actual_file.csv")

Which will produce within the same folder with the original SAS file, the desired .CSV one. If you want to have «;» as separator instead on «,» use write.csv2(aux, "actual_file.csv"). Anyway Strings are enclosed by » » so it should be fine.

by  • May 30, 2017 • Comments Off on Create and run SAS code in SAS Add-In for Microsoft Office

SAS programs in Excel, finally!When SAS Add-In for Microsoft Office was first created over a decade ago, SAS programmers were told to check their skills at the door. This new product was for non-programmers only. SAS programmers were invited to contribute to the experience by packaging their code in SAS stored processes, which end users would then run using point-and-click menus. But there was no way to write and run your SAS programs directly in Microsoft Excel or Word or PowerPoint.

This was a comfort to many SAS administrators, who wanted to provide SAS analytics to their end users but didn’t want them to have to learn to program. Or perhaps to even allow them to program. But, times have changed. Citizen data scientists have been practicing their coding skills, and now they want to mix it up in Microsoft Office. In response to this demand, SAS R&D has added the SAS programming environment — the parts that make sense, anyway — into SAS Add-In for Microsoft Office. You can write programs, run them, and drop the results into any part of your Microsoft Office document.

Here’s a short screencast of how it works in Microsoft Excel:

SAS programming in AMO

If you want to learn more and see a narrated demo from the principal developer, watch this interview with Tim Beese from SAS R&D. Tim shows the coding feature along with several other cool enhancements to SAS Add-In for Microsoft Office. As Tim explains, SAS administrators still have the final say when it comes to allowing Excel users to let loose with SAS code — they can enable the feature by role, and so grant this as a privilege at their discretion.

The first few minutes of this video shows some impressive integration with SAS Visual Analytics and Microsoft Excel. The SAS programming demo begins around the 5-minute mark.

The post Create and run SAS code in SAS Add-In for Microsoft Office appeared first on The SAS Dummy.

Понравилась статья? Поделить с друзьями:
  • Sap способы выгрузки в excel
  • Sap работа с excel
  • Sap отчеты в excel
  • Sap нет выгрузки в excel
  • Sap выгрузка в excel с заголовком