DATASETS Procedure

Example 9: Getting Sort Indicator Information

Features:

APPEND statement option: GETSORT

SORTEDBY data set option

Program

data mtea;
    length var1 8.;
    stop;
run;
data phull;
    length var1 8.;
    do var1=1 to 100000;
    output;
end;
run;

proc sort data=phull;
    by DESCENDING var1;
run;

proc append base=mtea data=phull getsort;
run;

ods select sortedby;

proc contents data=mtea;
run;

Program Description

The following example shows that a sort indicator can be inherited using the GETSORT option with the APPEND statement.
Create a "shell" data set that contains no observations.
data mtea;
    length var1 8.;
    stop;
run;
Create another data set with the same structure, but with many observations. Sort the data set.
data phull;
    length var1 8.;
    do var1=1 to 100000;
    output;
end;
run;

proc sort data=phull;
    by DESCENDING var1;
run;

proc append base=mtea data=phull getsort;
run;

ods select sortedby;

proc contents data=mtea;
run;
Sort Information Output
Sort Information
This example shows sort indicators using the SORTEDBY data set option and the SORT procedure.
A sort indicator is being created using the SORTEDBY data set option.
data mysort(sortedby=var1);
    length var1 8.;
    do var1=1 to 10;
    output;
end;
run;

ods select sortedby;

proc contents data=mysort;
run;
Sort Information Output
Sort Information
This example shows the sort indicator information using the SORT procedure.
A sort indicator is being created by PROC SORT.
data mysort;
    length var1 8.;
    do var1=1 to 10;
    output;
end;
run;

proc sort data=mysort;
    by var1;
run;

ods select sortedby;

proc contents data=mysort;
run;
Sort Information Output
Sort Information