ABSTRACT INTRODUCTION FILE IMPORT WIZARD



Similar documents
Pharmacy Affairs Branch. Website Database Downloads PUBLIC ACCESS GUIDE

Creating a Distribution List from an Excel Spreadsheet

ABSTRACT INTRODUCTION SAS AND EXCEL CAPABILITIES SAS AND EXCEL STRUCTURES

An Overview of REDCap, a secure web-based application for Electronic Data Capture

Autodesk Product Manager Tool

Reading Delimited Text Files into SAS 9 TS-673

Using DDE and SAS/Macro for Automated Excel Report Consolidation and Generation

SAS Tips and Tricks. Disclaimer: I am not an expert in SAS. These are just a few tricks I have picked up along the way.

Technical Paper. Reading Delimited Text Files into SAS 9

Exporting Client Information

SAS and Electronic Mail: Send faster, and DEFINITELY more efficiently

WorldShip Import Customer Addresses

Microsoft Business Contact Manager Version 2.0 New to Product. Module 4: Importing and Exporting Data

250.SCH: Uncashed Check Single CNAC Extract

Exporting Contact Information

Ad Hoc Reporting: Data Export

SAS Hints. data _null_; infile testit pad missover lrecl=3; input answer $3.; put answer=; run; May 30, 2008

User Manual - Sales Lead Tracking Software

SELF SERVICE RESET PASSWORD MANAGEMENT CREATING CUSTOM REPORTS GUIDE

Importing and Exporting Databases in Oasis montaj

Affiliate Program CSV Export User Guide

Follow these procedures for QuickBooks Direct or File Integration: Section 1: Direct QuickBooks Integration [Export, Import or Both]

- 1 - Guidance for the use of the WEB-tool for UWWTD reporting

Work with the MiniBase App

Microsoft Access Rollup Procedure for Microsoft Office Click on Blank Database and name it something appropriate.

WhatCounts Newsletter System Manual

How do I create a Peachtree (Sage 50) Payroll export file?

Quick Start User Guide

PC-MIS. IAPT Intermediate Database Creation Procedure. Patient Case Management Information System

Converting Microsoft Access 2002 to Pipe-Delimited ASCII Text Files

Importing and Exporting With SPSS for Windows 17 TUT 117

Content Management System

WorldShip Export Shipment Data

Tips to Use Character String Functions in Record Lookup

Process Document Campus Community: Create Communication Template. Document Generation Date 7/8/2009 Last Changed by Status

William E Benjamin Jr, Owl Computer Consultancy, LLC

Time Clock Import Setup & Use

Norwex Office Suite: The Consultant Experience

Purchase Agent Installation Guide

PharmaSUG Paper AD11

emarketing Manual- Creating a New

MLS 204: FlexMLS Contact Management & Client Portals

EXCEL IMPORT user guide

DIRECTIONS FOR SETTING UP LABELS FOR MARCO S INSERT STOCK IN WORD PERFECT, MS WORD AND ACCESS

Business Intelligence Tutorial

How To Use Optimum Control EDI Import. EDI Invoice Import. EDI Supplier Setup General Set up

Setting up Auto Import/Export for Version 7

Choosing the Best Method to Create an Excel Report Romain Miralles, Clinovo, Sunnyvale, CA

MONEY TRANSFER. Import & Approval User Guide

EXST SAS Lab Lab #4: Data input and dataset modifications

Using Pharmacovigilance Reporting System to Generate Ad-hoc Reports

Data Export User Guide

PrintShop Mail Database Fundamentals Guide

A Macro to Create Data Definition Documents

Query 4. Lesson Objectives 4. Review 5. Smart Query 5. Create a Smart Query 6. Create a Smart Query Definition from an Ad-hoc Query 9

Avery Wizard: Using the wizard with Microsoft Word. This is a simple step-by-step guide showing how to use the Avery wizard in word

How to transfer your Recipient Address Book from FedEx Ship Manager at fedex.ca to FedEx Ship Manager Software

SAS Macros as File Management Utility Programs

Invoice Quotation and Purchase Orders Maker

Generating a Custom Bill of Materials

Importing an ASCII File to Use on the TSC2 Using Trimble Survey Controller

Home Loan Manager Pro 7.1

Introduction to the Data Migration Framework in Microsoft Dynamics by Ruben Barron

Linking Telemet Orion to a Portfolio Accounting System

Electronic Remittance Advice (ERA) Processor

SAS Visual Analytics dashboard for pollution analysis

NAIP Consortium Strengthening Statistical Computing for NARS SAS Enterprise Business Intelligence

Analyzing Data Using Access

Informatics for Integrating Biology and the Bedside. i2b2 User Guide. Import Data View. Document Version: I2b2 Software Release: 1.

Paper Creating SAS Datasets from Varied Sources Mansi Singh and Sofia Shamas, MaxisIT Inc, NJ

Using Cost Recovery with Teraview

File Management Utility User Guide

SAS and Microsoft Excel for Tracking and Managing Clinical Trial Data: Methods and Applications for Information Delivery

Network Event Viewer now supports real-time monitoring enabling system administrators to be notified immediately when critical events are logged.

ACCESS Importing and Exporting Data Files. Information Technology. MS Access 2007 Users Guide. IT Training & Development (818)

A database is a collection of data organised in a manner that allows access, retrieval, and use of that data.

Tips on exporting your Oracle Apps reports to Excel. Introduction

PICAXE VSM Tutorial Part 4

9.1 SAS/ACCESS. Interface to SAP BW. User s Guide

SUGI 29 Coders' Corner

How to use MS Excel to regenerate a report from the Report Editor

IMPORTING AND EXPORTING CERTIFICATES IN IE AND FIREFOX FOR BPIA AND PRACS

Asset Management Automatic Financials Upload on the MITAS Internet Property Management site

Using Adobe Dreamweaver CS4 (10.0)

PassKey Manager. Schoolwires Centricity

Importing Excel File using Microsoft Access in SAS Ajay Gupta, PPD Inc, Morrisville, NC

NSSRS Desktop Database Version 11.0 User Guide Version 1.0 July 15, 2015

MoCo SMS Suite Quick Guides for Direct Marketing and CRM

COLLABORATION NAVIGATING CMiC

Advanced Excel 10/20/2011 1

MS Excel Template Building and Mapping for Neat 5

From Database to your Desktop: How to almost completely automate reports in SAS, with the power of Proc SQL

Enhanced Attendance Reporting for SmartLock Pro Plus OPERATOR GUIDE

Novell ZENworks Asset Management 7.5

Intellect Platform - Tables and Templates Basic Document Management System - A101

Catalog Creator by On-site Custom Software

Mail Merge: Create Mailing Labels Using Excel Data and Filtering the Contents in the Data

Working with Office Applications and ProjectWise

Extracting Publications and Citations from Scopus

At the end of this lesson, you will be able to create a Request Set to run all of your monthly statements and detail reports at one time.

Transcription:

SAS System Generates Code for You while Using Import/Export Procedure Anjan Matlapudi and J. Daniel Knapp Pharmacy Informatics, PerformRx, The Next Generation PBM, 200 Stevens Drive, Philadelphia, PA 19113 ABSTRACT It is a very common programming task to input data from flat files and export data into flat files. Most of these files are delimited text (tab, pipe, comma, etc.) or CSV files come from various sources such as third party vendor software. Earlier we demonstrated techniques to read complex flat files extracted from DB2 data source. Many of us use different approaches to read and write data files such as text, ASCII, sequential or flat files. Some of us might not be aware of how the SAS system generates code. This paper illustrates an easy way to obtain the actual SAS code while importing or exporting data from an external source using either the IMPORT/EXPORT wizard or IMPORT/EXPORT procedures. INTRODUCTION The SAS system has an excellent facility for importing and exporting data. We import flat files in the SAS system to perform further analysis and output results based on our business requirements. In this paper we will demonstrate an easy method to obtain SAS system generated code using the SAS IMPORT/EXPORT wizard and IMPORT/EXPORT procedures. FILE IMPORT WIZARD We now demonstrate the steps to obtain SAS generated code from the IMPORT wizard, specifically importing a tab delimited text file. We hope the following steps and screen shots will help you to import and obtain the SAS system generated code. Step 1: Go to File menu and click on File Import tab as shown below. 1

Step 2: You have an option to choose file type; in this example highlight tab delimited file. Step 3: Locate the file by browsing the directory path and highlight file name to select. Step 4: Input a name for the data set ( by default the imported dataset will reside in the SAS work directory unless you specify otherwise). Click the Finish button. 2

***Step 5: This is most important step to remember. Open a new program window or existing program window and press the F4 key (recall key), and magically the code will appear. You have the option now to make changes to the logic. FILE EXPORT WIZARD This same methodology applies to the EXPORT wizard. FILE IMPORT PROCEDURE You can also import any kind of delimited flat files using the file IMPORT procedure and get the SAS system generated code as shown below. *---Import Procedure to Import Comma Delimited Flat File---*; proc import datafile='c:\anjan Personnel\NESUG 2012\Import Export\Comma Delimited Text file.txt' out=dataout dbms=dlm; delimiter=","; /********************************************************************** * PRODUCT: SAS * VERSION: 9.2 * CREATOR: External File Interface * DATE: 10SEP12 * DESC: Generated SAS Datastep Code * TEMPLATE SOURCE: (None Specified.) ********************************************************************** data WORK.DATAOUT ; %let _EFIERR_ = 0; infile 'C:\NESUG 2012\Import Export\Comma Delimited Text file.txt' delimiter = MISSOVER DSD lrecl=32767 firstobs=2 ; informat Row best32. ; in informat Claim_Number best32. ; in informat Ammount_Paid comma32. ; format Row best12. ; 3

input Row Member_Number $ Claim_Number Date_Filled Ammount_Paid; if _ERROR_ then call symputx('_efierr_',1); /* set ERROR detection macro variable */ You can also import CSV files as shown and obtain the system generated code by pressing F4 key. *---CSV File---*; proc import datafile='c:\anjan Personel\NESUG 2012\Import Export\CSV_Formated.csv' out =CVSOut; FILE EXPORT PROCEDURE Similarly, you can also work with PROC EXPORT using the file export wizard or running the following code to get the system generated code. PROC EXPORT DATA=connmadel OUTFILE='C:\NESUG 2012\Import Export\CommaDelimited.txt' DBMS=DLM replace ; DELIMITER=; RUN; By pressing F4 key on a new program window this following code will be generated. data _null_; %let _EFIERR_ = 0; file 'C:\NESUG 2012\Import Export\CommaDelimited.txt' delimiter= DSD DROPOVER lrecl=32767; if _n_ = 1 then do; put "Row" "Member_Number" "Claim_Number" "Date_Filled" "Ammount_Paid" ; end; set CONNMADEL end=efieod; format Row best12. ; do; EFIOUT + 1; put Row @; put Member_Number $ @; 4

put Claim_Number @; put Date_Filled @; put Ammount_Paid ; ; end; if _ERROR_ then call symputx('_efierr_',1); if EFIEOD then call symputx('_efirec_',efiout); You can cleanup this as shown below to output delimited text file. data _null_; file 'C:\Anjan Personel\NESUG 2012\Import Export\CommaDelimited.txt' delimiter= DSD DROPOVER lrecl=32767; set CONNMADEL(drop=row) ; put Member_Number $ @; put Claim_Number @; put Date_Filled @; put Ammount_Paid ; if _ERROR_ then call symputx('_efierr_',1); IMPORT/EXPORT THROUGH MACRO VARIABLES Once you change the system generated code as per the logic, you can use positional macros to work with many files as shown below. *--Files import using Macro Variable---*; %FileImport (InFileName =,OutFileName=); proc import datafile="c:\nesug 2012\Import Export\In &In_FileName..txt" out=&outfilename. dbms=dlm; delimiter=","; %mend; %FileExport (InFileName =FileIn1,OutFileName=FileOut1); %FileExport (InFileName =FileIn2,OutFileName=FileOut2); The following logic is used to export many files using macro variables. *--Files Export using Macro Variable---*; %macro FileExport(FileIn=, FileOut=); data _null_; %let _EFIERR_ = 0; file "C:\NESUG 2012\Import Export\&FileOut..txt" delimiter= DSD DROPOVER lrecl=32767; set &FileIn. (drop=row) ; put Member_Number $ @; put Claim_Number @; put Date_Filled @; put Ammount_Paid ; ; if _ERROR_ then call symputx('_efierr_',1); 5

%mend; *--Passing FileName as Psotional Marco Vriable---*; %FileExport (FileIn=commadel, FileOut=CommaDelout1) %FileExport (FileIn=commadel, FileOut=CommaDelout1) CONCLUSION We hope this paper will be useful to educate SAS users to use the SAS IMPORT/EXPORT wizards and IMPORT/EXPORT Procedures, in conjuction with the F4 short cut key to obtain SAS generated code. You can modify the code based on your needs and preferences. We also demonstrated use of macro variables to handle multiple files and datasets. REFERENCES Anjan Matlapudi and J. Daniel Knapp Challenge! Reading Mainframe Hex Delimited Flat File Where Each Line Has Different Layout. Global SAS Forum 2010 Coders Corner, Paper 107-2010 Kuligowski, T. Andew. Datalines, Sequential Files, CVS, HTML and More Using INFILE and INPUT Statements to Introduce External Data into the SAS System, SUGI 31 Tutorials Paper 228-31. AKNOWLEDGMENTS We would like to acknowledge Mr. Shimels Afework, Senior Director, PerformRx. PerformRx provides pharmacy benefit management (PBM) services through proactively managing escalating pharmacy costs while focusing on clinical improvement and financial results. CONTACT INFORMATION: Your comments and questions are valued and encouraged. Contact the authors at \ Name Anjan Matlapudi Senior Pharmacy Analyst, Pharmacy Informatics Department Address PerformRx, The Next Generation PBM 200 Stevens Drive Philadelphia, PA 19113 Work Phone: (215)937-7252 Fax: (215)863-5100 E-mail: anjan.matlapudi@performrx.com anjanmat@gmail.com Name Knapp, J. Daniel, MBA Senior Manager, Pharmacy Informatics Department Address PerformRx, The Next Generation PBM 200 Stevens Drive Philadelphia, PA 19113 Work Phone: (215)937-7251 Fax: (215)863-5100 E-mail: Daniel.Knapp@performrx.com Jdjeep57@yahoo.com SAS is a registered trademark or trademark of SAS Institute, Inc. in the USA and other countries. 6