using proc datasets for efficiency
Download
Skip this Video
Download Presentation
Using Proc Datasets for Efficiency

Loading in 2 Seconds...

play fullscreen
1 / 8

using proc datasets for efficiency - PowerPoint PPT Presentation


  • 270 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'using proc datasets for efficiency' - betty_james


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
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

proc datasets an overview
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
libname input sas data library proc datasets library input datasets commands run
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.
append vs set
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;

change command
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;

copy command
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;

modify command
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
slide8

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
ad