Proc datasets tips

by Irina 28. July 2007 11:46
Splitting the data.frame into 3 parts
data en1(drop = course) en2 en3;
set deet07.dx2007;
if 0 <= _N_ <= 1000 then output en1;
else if 1000 < _N_ <= 2000 then output en2;
else if 2000 < _N_ <= 3000 then output en3;
run;

/* 1. list contents of last dataset used, en3 */
proc contents data= _LAST_;
run;
/* 2. list contents of all datasets in the work library */
proc contents data=work._ALL_;
run;
/* 3. list datasets in the work library */

proc contents data=work._ALL_ nods;

run;

/* 4. proc datasets version of above - list all datasets in the specified library */
proc datasets library=work;
quit; run;

/* 5. describe a single dataset */
proc datasets library=work;
contents data=en1;
quit; run;

/* 6. describe all work datasets */
proc datasets;
contents data=_ALL_;
quit; run;

/* 7. copy all datasets in work to stud07, excluding e3*/
proc datasets;
copy in=work out=stud07;
exclude e3;
quit; run;
 

/* 8. delete everything in work (deletes datasets and formats) */
proc datasets library=work kill;
quit; run;


/* 9. delete just the datasets */

proc datasets library=work memtype=data kill;
quit; run;


/* 10. move all datasets except en3 from stud07 to work */

proc datasets;
copy move in=stud07 out=work;
exclude en3;
quit; run;


/* 11. move just one dataset from stud07 to work */

proc datasets;
copy move in=stud07 out=work;
select en3;
quit; run;


/* 12. delete an individual dataset */
proc datasets library=work;
delete en3;
quit; run;


/* 13. change the name of a dataset */
proc datasets library=work;
change en2=en4;
quit; run; 


/* 14. append datasets - note this is quicker than using a set command, as only the appended dataset is read in */
proc datasets library=work;
append out=en4 data=en1;
quit; run;


/* 15. rename a variable */

proc datasets library=work NOlist;
modify en1;
rename student=personid course = course_cd;
run; quit;

About the author

Irina Spivak Irina Spivak
Team Leader at G-Stat. More...


Send mail Email

Authors

Blogroll

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010

    Sign in

    eXTReMe Tracker