1 / 8

Using Proc Datasets for Efficiency

Using Proc Datasets for Efficiency. Originally presented as a Coder’s Corner @ NESUG2000 by Ken Friedman Reviewed by Karol Katz. Used to manage SAS Datasets List,change, append and repair datasets Create and maintain indexes

betty_james
Download Presentation

Using Proc Datasets for Efficiency

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Proc Datasets for Efficiency Originally presented as a Coder’s Corner @ NESUG2000 by Ken Friedman Reviewed by Karol Katz

  2. Used to manage SAS Datasets List,change, append and repair datasets Create and maintain indexes Proc DATASETS includes all capabilities of the APPEND, CONTENTS and COPY procedures Procedure commands execute with a RUN command or another DATASETS command The procedure remains active until another procedure, dataset statement, or QUIT command is executed Proc Datasets, an Overview

  3. LIBNAME input ‘SAS-data-library’ ;PROC DATASETS LIBRARY = input ;DATASETS commandsRUN; • APPEND vs SET • SET command reads ALL observations from the datasets being concatenated. • The APPEND command ONLY reads the observations from the dataset being appended. • If the two datasets do not contain the same variable names, types or lengths, you can use the FORCE option to force the append to take place.

  4. APPEND vs. SET PROC DATASETS; APPEND OUT = membr_b DATA = Membr_a (WHERE = (year=2004)); QUIT; RUN; DATA membr_b; SET membr_b membr_a (WHERE = (year=2004)); RUN;

  5. CHANGE Command • Used to rename one or more members within a SAS library • Specify old name on left of the equals sign and new name on right • The following example renames two temporary datasets PROC DATASETS ; CHANGE temp1 = Jan_Mar04 temp2 = Apr_Jun04; RUN;

  6. Copy command • To copy or move a SAS a member from one library to another • To limit copying to specific members use either SELECT or EXCLUDE options • To move a member from one library to another and then delete the original member, use the MOVE option LIBNAME lib1 ‘SAS-data-library1’; LIBNAME lib2 ‘SAS-data-library2’; PROC DATASETS; COPY in = lib1 out = lib2 MOVE; SELECT member1 member2; * / memtype = (data); RUN;

  7. Modify Command • Works only on one dataset at a time • Allows you to change or specify formats, informats, and labels, rename variables and create and delete indexes • For an existing dataset the MODIFY command is the best way to make changes because no observations are read in or written out during processing • Using a data step with a set statement you can also make changes, however all oberservations are read in & written out. In a large dataset time and storage can be significant

  8. MODIFY Example:LIBNAME input ‘SAS-data-library’ ;PROC DATASETS LIBRARY = input ; MODIFY income(LABEL=‘Household Income’); RENAME oldvar=newvar; LABEL newvar=‘originally called old’; FORMAT income comma11.2; RUN; DATASETS procedure is interactive • Commands execute immediately in the order they appear • Be cautious when working with this procedure

More Related