Category Archives: Data

Undo an Action in Microsoft Excel with the SAS Add-In for Microsoft Office Installed

SAS Even though we have Maintenance Release 2 installed on our SAS clients, we will still get undo problems in Excel.  Here is one more step that needs to be performed:

The issue described in SAS Note 36601: Cannot undo changes in Microsoft Excel when the SAS® Add-In for Microsoft Office is installed can be fixed by applying the second maintenance release for SAS 9.2 (TS2M2).

However, after you apply the maintenance release, you must also select the option Always Prompt for Data Source. This option can be found under SAS –> Options on the Tasks page. See Usage Note 37701: Additional SAS® Add-In for Microsoft Office configuration is required to restore functionality of the Undo button in Microsoft Excel.

Sending SAS Enterprise Guide Data to Microsoft Excel

saslogo A strong point of SAS Enterprise Guide is that it interacts seamlessly with many data types using the Microsoft Jet Engine (Excel .xls, Access .mdb, dBase .dbf, Lotus.wk?, Paradox .db, and text files .txt .csv etc).  To provide even more flexibility, there are also a few different ways in Enterprise Guide to output data to Excel.  A user can export their data to Excel, export to Excel as a step in a project, or they can right-click on a data set and select Send To –> Microsoft Excel.  The latter is a convenient feature that many users are comfortable with, but in Enterprise Guide 4.1, your results might not be what you expect.

One data set that we were working with included a date variable which was stored as a DATE9. format.  A user complained that every time she exported the data it ended up in DATETIME format, and all of the zeroes from the time complicated her project.  I tried to replicate her problem many times by exporting the same data set into Excel and I ended up with DATE9. every time.  I finally asked her to send screen shots of what she was doing, and noticed what she called “export” was actually using “Send To –> Microsoft Excel”.  I explained that to get the results she wanted, she needed to use the “real” export technique.  After I solved this problem, I browsed to support.sas.com and sure enough, SAS had already identified this issue in Microsoft Excel might not maintain date formats in SAS Enterprise Guide.  Apparently this issue is fixed in Enterprise Guide 4.2 but I have not tested it yet.

SAS Enterprise Guide 4.1 Hotfix 41EG14 Available

SAS recently released Hotfix 41EG14 for Enterprise Guide 4.1.  The hotfix resolves issues identified in:

  • Problem Note 39149: The SAS Enterprise Guide editor’s width of caret position panel within the status bar does not accommodate for large row and column number schemes
  • Problem Note 38003: Unable to edit existing parameter in SAS® Enterprise Guide®
Enterprise Guide 4.1 Hot Fix 41EG14 (282)

Add Leading Zeroes to SAS Data

saslogo You probably have many SAS data sets that you regularly work with where numbers are stored as text for formatting purposes.  A great example is the social security number, and many other customer, product, or invoice numbers are formatted similarly.  They frequently utilize leading zeros in their storage and display.  You probably also frequently receive data from colleagues where the same variable is formatted as a numeric value missing the leading zeros.  The join that you were going to do with your data and the data received from the colleague just won’t work.  Here is a little SAS code that can turn your colleague’s data into a match for yours, and I’ll use social security number (SSN) in this example:

data DatasetName ;
set InputDataset ;
length ssn_char $9. /* New Character var for SSN                    */
ssn_char = put(ssn,z9.) ; /* Put the Numeric SSN with the Z9. format   */
drop ssn ; /* Housecleaning to drop the numeric SSN    */
rename ssn_char = ssn ; /* Renamed Char SSN to make our Join easier */
run ;

By creating a new Character variable of SSN, I can simply put the Numeric SSN with Z9. format into the variable.

The format Z9. states the variable should be 9-bytes, and for each byte less than 9, put a leading zero in front of the var.

No strip or trim is necessary either.

I used this in the past with a transaction number I was creating (numeric) and later wanted to display it in a title with leading zeros [Example:  had 123 as the value, put it with a Z10. and the display in the title was 0000000123].

Thanks to Paula for showing me this trick!

SAS OLAP Server Names

saslogo SAS OLAP Server names for cubes, dimensions, hierarchies, measures, and member properties follow these general rules:

  • can be up to 32 characters in length
  • can contain embedded blanks

If the name has embedded blanks or characters other than letters of the Latin alphabet, numbers, or underscores, then PROC OLAP formats the name as a name literal, which means that it is enclosed within quotation marks followed by the letter n. (Name literals enable you to use special characters or blanks that are not otherwise allowed in SAS names.) Here are some examples:

CUBE=’Financials@HQ’n

DIMENSION ‘Product@Work Dimension’n hierarchies=(Product@Work Hierarchy’n)

HIERARCHY ‘Product@Work Hierarchy’n levels=(prodtype product)

  • can contain mixed-case letters

SAS stores and writes the variable name in the same case that is used in the first reference to the variable. However, when SAS processes a variable name, SAS internally converts it to uppercase. You cannot, therefore, use the same variable name with a different combination of uppercase and lowercase letters to represent different variables. For example, cat, Cat, and CAT all represent the same variable.

  • do not contain periods (.)

These guidelines assume that the SAS Workspace Server is running with the VALIDVARNAME= system option set to ANY. If the SAS Workspace Server is not running with VALIDVARNAME=ANY, then you can either add code on the Submit SAS Code tab in the Advanced Options dialog box to set the option, or you can modify your names to meet the naming requirements that the server is running with. For more information about the VALIDVARNAME= option, see "VALIDVARNAME= System Option" in SAS Language Reference: Dictionary.

Quickly Comment and Uncomment SAS Code

SAS Institute Inc.

I attended SAS Programming 3: Advanced Techniques and Efficiencies training recently at the SAS’ Austin Training Center.  Programming 3 demonstrates many ways to make your SAS code and programs more efficient, but I also picked up one tidbit that makes coding and testing even easier.  When using the enhanced editor, to create comments in your code or comment out code you do not want to run, merely highlight or select the block or statements to comment with your mouse.  Now type the CTRL-/ key combination and your SAS code will include the required /* and the beginning and */ at the end of each selected line.  To uncomment a block or code or statement, highlight or select it and type the CTRL-Shift-/ key combination.  I did notice that if I select only one word on a line or merely have my cursor positioned anywhere within my code that the key combination will operate on the entire line which contains the highlighted word or cursor.  The quick commenting technique only works in the Windows version of the enhanced editor.  It will not work in the standard SAS program editor or on non-windows systems.

The Best Conversion Utility: Convert

Convert - v.4.1 - 779.54 KB

Here is a utility that I have used for a long time.  Convert does exactly what the name suggests: converts just abbout any unit of measure in an easy, straightforward way.  The program is small and fast.  Highly recommended.

from joshmadison.com:

Convert is a free and easy to use unit conversion program that will convert the most popular units of distance, temperature, volume, time, speed, mass, power, density, pressure, energy and many others, including the ability to create custom conversions!

convertani

RSS Feeds for USGS River and Reservoir Elevation Gage Data

NOAAYou might currently use the local newspaper’s web site to obtain recent elevation data for the reservoir you are fishing or the river you are canoeing.  Or if you fish or float on a number of water bodies, you might have to browse a number of controlling authorities sites (including the US Geological Survey) to get gauge data.  The National Oceanic and Atmospheric Administration (NOAA) has packaged all of the Observed River Conditions data into RSS feeds so you have real-time gauge data delivered to your inbox.  You can subscribe to gauge observations, forecasts, or alerts (handy if you live in the flood plain).  The national home page for this service is at http://www.weather.gov/ahps/rss/observed.php, with links to break down data by state, county, or gauge.

NOAA includes a Product Description Document (PDD) titled “Experimental Use of Really Simple Syndication (RSS) for Distribution of Advanced Hydrologic Prediction Service (AHPS) Information” that includes this description:

The National Weather Service is responsible for making its weather, water and climate information widely available to taxpayers using commonly accepted standards and techniques. One of the most widely accepted, available, and cost effective means of accomplishing this objective is the use of web services via the internet. The NWS has implemented Advanced Hydrologic Prediction Service (AHPS) as a corporate-wide HTTP-based web service for disseminating hydrologic information. This service has allowed users instant access to current NWS hydrologic information via Internet connections to personal computers equipped with industry standard browsers.

A rapidly evolving technology across the United States is the ability to access internet content via portable wireless devices. The Really Simple Syndication (RSS) format of AHPS information, will allow for a means of a user-driven public notification of AHPS products to cellular telephones or personal digital assistant (PDA). The RSS format will be provided for: 1) AHPS observations, 2) AHPS routine forecasts and 3) AHPS observations and forecasts that reach “alert” thresholds. The “alert” threshold is determined by the Weather Forecast Offices and is based on locally appropriate action stage that is always a stage below flood stage. This “alert” capability can be used to trigger further review of hydrological and meteorological conditions.

The AHPS RSS products will include the most recent observations, and when appropriate the greatest forecast value and the last forecast value from an individual AHPS time series file (in xml format). The AHPS RSS product will also include the internet address to the AHPS hydrograph page. A null AHPS RSS ”alert” product will be available to indicate non-alert conditions – if/when non-alert conditions exist.

GPSBabel 1.3.6

GPSBabel - v.1.3.6 - 1.19 MB

I just used this software this morning to merge three tracks together in a .gpx file.  Works great!  I now want to try the .gpx to .kml conversion features.  It supports a HUGE list of formats.

from GPSBabel.org:

GPSBabel lets you move data between popular GPS systems such as those from Garmin, Magellan or a large number of map programs.

GPSBabel is Free Software. You are free to use it within terms of the GNU Public License. The punch line of this license is that it lets you modify the program and redistribute it, but you also have to share your modifications with others.

Environmental/Natural Resource Tools for ArcPad

Environmental/Natural Resource Tools for ArcPad - v.1.0 - 104.76 KB

This suite of tools, located on a single toolbar, allows environmental, agriculture and other natural resource field workers to make sampling grids, calculate statistics for field data attributes, select which layers should be editable and navigate to specific field locations using ArcPad.

The tools download includes a read_me.txt file containing installation instructions and how each tool can be used. The tools are designed for use in ArcPad 6.0.2 and later. Although they might well be usable in older versions, this testing has not been done.