Type : EXTERNE
The macro operates on an existing SAS table whose name is provided as a parameter. No data is created or read from SASHELP.
| 1 | %macro DI_UTIL_TRUNCATE_TABLE( TABLE ) ; |
| 2 | |
| 3 | *------save caller environment------; |
| 4 | %local callerobs; |
| 5 | %let callerobs = %sysfunc(getoption(obs)); |
| 6 | %local callernotes; |
| 7 | %let callernotes = %sysfunc(getoption(notes)); |
| 8 | |
| 9 | |
| 10 | *------cport zero obs of the table silently to capture table definition------; |
| 11 | options obs=0 nonotes; |
| 12 | filename tranfile temp; |
| 13 | PROC CPORT file=tranfile DATA=&TABLE; RUN; |
| 14 | %IF &syserr ne 0 %THEN %goto EXIT; |
| 15 | |
| 16 | |
| 17 | *------cimport the empty table definition------; |
| 18 | PROC CIMPORT INFILE=tranfile DATA=&TABLE extendsn=no; RUN; |
| 19 | %IF &syserr ne 0 %THEN %goto EXIT; |
| 20 | options obs=&callerobs &callernotes; |
| 21 | %put NOTE: %qupcase(&TABLE) has been truncated.; |
| 22 | |
| 23 | |
| 24 | %EXIT: |
| 25 | options obs=&callerobs &callernotes; |
| 26 | |
| 27 | %mend DI_UTIL_TRUNCATE_TABLE; |