Presentation is loading. Please wait.

Presentation is loading. Please wait.

File Sharing and Processing Grouped Data

Similar presentations


Presentation on theme: "File Sharing and Processing Grouped Data"— Presentation transcript:

1 File Sharing and Processing Grouped Data
HRP223 – 2011 November 14th, 2011 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and international treaties. Unauthorized reproduction of this presentation, or any portion of it, may result in severe civil and criminal penalties and will be prosecuted to maximum extent possible under the law.

2 Formats Saved in Libraries
* x "mkdir C:\Projects\hrp223\cportExample"; libname cportex "c:\projects\hrp223\cportexample"; proc format library = cportEx; value isMale 0 = "Female" 1 = "Male" . = "Missing" other = "** bad **" ; run; Save the format here instead of in work. SAS is pushing this idea.

3 Your library name goes here.
Where to Find Formats SAS and EG look for formats in the work library. You can tell it to look in other libraries with a line like this: options fmtsearch = (cportEx work); Your library name goes here.

4 Sharing Files If everyone on your team uses the same version of SAS you can send datasets and catalogs via encrypted . Send both the files in the library and teach the recipient about options fmtsearch . data cportEx.stuff; format sex isMale.; input ID age sex; datalines; 1 83 1 2 82 0 ; run;

5 proc cport If you need to share datasets and formats across platforms (including 32 vs 64 bit Windows SAS), store the library in cport file and send that (via encrypted ). proc cport library = cportEx file="C:\Projects\hrp223\cportExample\example.cport" memtype = all; run; Send this one.

6 proc cimport Use proc cimport on the other machine:
libname cportEx "C:\Projects\hrp223\cportExample"; options fmtsearch = (cportEx work); proc cimport library = cportEx file = "C:\Projects\hrp223\cportExample\example.cport" ; run;

7 No Formats… If somebody forgets to send you the formats you can include this line and the data will display unformatted without errors: options nofmterr;

8 32bit vs. 64 bit SAS The different versions of SAS optimize datasets and formats to work as fast as possible. You can open a 32 bit SAS dataset with a 64 bit version of SAS but it is slower than necessary. Formats saved in permanent libraries (as catalogs) may have problems opening on different platforms/operating systems.

9 Analysis Procedures by…
You may need to work on groups of subjects (or other things). That is, you want to organize your data by some grouping variable. Most analysis procedures will let you do this easily.

10 Means by Group does not need to be sorted (class statement)
if the data is already sorted (by statement)

11 Summary Statistics

12 Complicated Processing by Group
Say you want to get the first or last element in a sorted list. Sort the data if needed. Include a by THING statement in a data step. Use the automatically created first.THINGY and/or last.THING variables Automatically make first.act and last.act variables. Set first.act = 1 on first record of an act group of records and last.act = 1 on last record of the groups. 1 = true in a logic check

13 Complex Running Totals
Say you want to get the average radiation from the first two chest x-rays that a patient receives and the visits are not in order. Sort the data by patient and date. In a data step: Set a visit counter to 0 on first visit. Add one for every subsequent visit. Keep the records where visit < 3.

14 Many Ways to Sort Choose the Filter and Sort, the Query Builder or the Data > Sort Data… context sensitive menus.

15 The PDV does not remember the old values.
Once the data is subsetted and ordered, use a data step and process by the subject ID. The PDV does not remember the old values. data firstTwo; set sorted; by dude; if first.dude then visit = 1; else visit = visit + 1; run;

16


Download ppt "File Sharing and Processing Grouped Data"

Similar presentations


Ads by Google