dataset3 - Building a SAS Data Set 3 LAG function assign...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Building a SAS Data Set --- 3 LAG function – assign the value of a variable in the last observation Example 3.1 data external; infile ‘a:\dataset2\china#1.dat’; input year total exports imports; lag_exp = lag(exports); ch_exp = exports - lag_exp; lag_imp = lag(imports); ch_imp = imports - lag_imp; drop total; run; proc print data=external; title 'Example 3.1'; run; Example 3.1 11:00 Thursday, August 10, 2000 1 OBS YEAR EXPORTS IMPORTS LAG_EXP CH_EXP LAG_IMP CH_IMP 1 1955 1.41 1.73 . . . . 2 1956 1.65 1.56 1.41 0.24 1.73 -0.17 3 1957 1.60 1.51 1.65 -0.05 1.56 -0.05 4 1958 1.98 1.89 1.60 0.38 1.51 0.38 5 1959 2.26 2.12 1.98 0.28 1.89 0.23 32 1986 27.01 33.08 25.92 1.09 34.33 -1.25 33 1987 34.71 33.40 27.01 7.70 33.08 0.32 34 1988 40.64 39.85 34.71 5.93 33.40 6.45 35 1989 43.44 39.14 40.64 2.80 39.85 -0.71
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
DROP and KEEP -- keep only some of the variables Example 3.2 data external; infile ‘a:\dataset2\china#1.dat’; input year total exports imports; lag_exp = lag(exports); ch_exp = exports - lag_exp; lag_imp = lag(imports); ch_imp = imports - lag_imp; keep year exports imports ch_exp ch_imp; run; proc print data=external; title 'Example 3.2';
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 9

dataset3 - Building a SAS Data Set 3 LAG function assign...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online