Make a dataset option that works for all datasets that adds a variable to the PDV that is essentially the observation number. Add it such that it can be used by the procedure or the data step reading the dataset.
Hypothetical Examples:
data cars (obsnum=M Keep=Make Model N );
do p=1 by 1 until (Last.Make);
set SASHELP.CARS( obsnum=N obs=25);
by Make;
if p<4
then output;
end;
Run;
WORK.CARS:
Make | Model | N | M |
Acura | MDX | 1 | 1 |
Acura | RSX Type S 2dr | 2 | 2 |
Acura | TSX 4dr | 3 | 3 |
Audi | A4 1.8T 4dr | 8 | 4 |
Audi | A41.8T convertible 2dr | 9 | 5 |
Audi | A4 3.0 4dr | 10 | 6 |
PROC TRANSPOSE DATA=SASHELP.FISH(obsnum=N obs=9)
OUT=LONG_TRANSPOSE
PREFIX=Length
NAME=Source
;
BY Species N;
VAR Length1 - Length3;
RUN;
WORK.LONG_TRANSPOSE:
Species | N | Source | Length1 |
Bream | 1 | Length1 | 23.2 |
Bream | 1 | Length2 | 25.4 |
Bream | 1 | Length3 | 30 |
Bream | 2 | Length1 | 24 |
Bream | 2 | Length2 | 26.3 |
Bream | 2 | Length3 | 31.2 |
Bream | 3 | Length1 | 23.9 |
Bream | 3 | Length2 | 26.5 |
Bream | 3 | Length3 | 31.1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.