Posts

How to check how the dataset got sorted without looking at the code?

Image
You can do this manually or programmatically. Manual Approach: Right click on the data set in the explorer and go to properties, then go to the details tab and see the sorted by values (Works only if you use Windows operating system) Programmatic approach: Use proc contents and create an output dataset of the contents. The sorted and sortedby columns will give us the details in about how the dataset got sorted in place. Note: proc contents will give missing values if the dataset isn’t sorted. *Example; proc sort data =sashelp.class out =class; by name sex age; run ; proc contents data =class out =contents noprint ; run ; proc print data =contents; var memname name sorted sortedby; run ; (' ’)

How to add leading zeros to numeric variables

Have you ever asked to create a variable with leading zeros? I mean 1 to 001 and 2 to 002. If you were, do you know how.... SAS has a special numeric format Zw.d . which can include leading zeros. Zw.d Format in which, w :   Width of variable. d :  Decimal Point. Zw.d format writes standard numeric data with leading 0's.  The Z w . d  format is similar to the  w.d  format except that Z w . d  pads right-aligned output with 0s instead of blanks.  (Ref: SAS 9.2 Language Reference : Dictionary, 4th edition); Let me give you a scenario where this can be very useful: You have a variable called site with the numbers as 101, 999, 1001 and 1200. If you want to create a USUBJID variable with fixed length for all the subjects, we need to modify the site variable variables to fixed length. (length=4). You can do that using Z4.d format. Note: As this is a numeric format, this can be applied to numeric variables only. *z4.format is used to a...

How to extract year information from three formats of dates in a dataset? (IMPUTED Dates)

Image
The LINKEDIN SAS Professionals group had a question on How to extract year information from three formats of dates in a dataset? (IMPUTED Dates). There were a number of good suggestions submitted. Here is a summary of the suggestions: **************************************************************; *Method1: Using scan or substr with length functions; data temp; infile datalines; input date: $10. ; datalines; 1998 2008 01-1998 01-2008 01-01-1998 01-01-2008 ; run; data temp; set temp; if length (date) = 4 then year = input(substr (date, 1 , 4 ), best32 .); else if length (date) = 7 then year = input(substr (date, 4 , 4 ), best32 .); else if length (date) = 10 then year = input(substr (date, 7 , 4 ), best32 .); run ; *(or); data temp; set temp; if length (date) = 4 then year = input (date, best .); else if length (date) = 7 then year = input(scan (date, 2 , '-' ), best .); else if length (date) = 10 then year = input(scan (date, 3...

Check How easy to find ERROR/WARNING/UNINITIALIZED messages in the LOG window

Image
Today I will tell you how easy it is to find ERROR/WARNING/UNINITIALIZED messages inside the LOG window. What you need to do is….Create a list of shortcut keys inside your SAS Toolbar for the LOG window. This is quick and also saves time. You  can customize toolbar settings using the Customize tools dialog box. You can open the Customize tools dialog box by 1) Enter TOOLEDIT (one word) in the command bar or 2) Go to, TOOLS ________ CUSTOMIZE or 3) Right click on the Toolbar and select CUSTOMIZE . Adding a Tool to the Toolbar To add a tool to the toolbar, just click the Add tool button to add a blank tool to the toolbar list. Enter a SAS command in the Command box as mentioned below. You can also add icon to the SAS command as I did below. Adding these7 icons means you can look for ERROR/WARNING/UNINITIALIZED messages and the two arrow signs will help to find the next or previous ERROR/WARNING/UNINITIALIZED messages.

Results and Lessons from the CDISC SDTM/ADaM Pilot Project

Results and Lessons from the CDISC SDTM/ADaM Pilot Project http://www.bettermanagement.com/seminars/seminar.aspx?mode=play&L=14684 Get registered free… and listen to 1 hour Audio seminar by… Cathy Barrows, Ph.D Chris Holland Edvard D. Helton, Ph.D Tanyss Mason Program Content: The CDISC SDTM/ADaM Pilot Project was conducted as a collaborative pilot project with FDA and Industry. The objective of the pilot project was to test how well the submission of CDISC-adherent datasets and associated metadata met the needs and the expectations of both medical and statistical FDA reviewers. In doing this, the project also assessed the data structure, resources and processes needed to transform data from a data source into the SDTM and ADaM formats, and to create the associated metadata. An additional goal was to produce a worked example implementation of the CDISC standards available at that time, including the Define.xml file. This webcast will review the experiences, results, and...

Importing Excel/DBF Files to SAS Datasets Using DDE

Importing Excel Files Into SAS Using DDE What in the world is DDE and why use it? Good question... DDE is “Dynamic Data Exchange” and is a method of accessing data from one MS-Windows application by another. As a SAS user, you can use DDE within a DATA step to import data into SAS and export data from SAS. Using DDE involves SAS code and statements that other MS-Windows applications understand. But, why bother with DDE when other methods are available? What about the IMPORT and EXPORT procedures? Or, Open Database Connectivity (ODBC)? How about SAS Enterprise Guide? These alternatives are useful under the right conditions. For example, the PROC IMPORT and PROC EXPORT are simple to use, but are limited in the way you can define your data and these procedures require you license SAS/ACCESS For PC Formats. Bummer. ODBC is also simple to use, but importing data into SAS using ODBC requires you license SAS/ACCESS For ODBC. Bummer again. And, the new Excel LIBNAME engine? Oh, that also req...

Multiple Graphs on One Page Using SAS/GRAPH® V9

I am not sure what other fellow SAS Programmers think about SAS Graphs, but I think they are easy to generate than tables…. I was amazed by how easy it was to get more than 1-2 graphs in single page. While surfing on the net, I found a nice SUGI paper which deals with the ways of putting multiple graphs in one single page. This paper provides 3 different methods (PROC GREPLAY, the Data Step Graphics Interface (DSGI), and ODS LAYOUT) to put multiple figures on a one single page. Multiple Graphs on One Page Using SAS/GRAPH® V9