hello
i need to make sure about kind of code whether it is correct or not
first i usually use creating a variable (var_lag) to calculate the delta of that var for instance total assets( TA_lag) or inventory
then i used the statement as follows
data real_em;
set erm_var;
CFLO_real= (CSFO/TA_lag);
TA1=(1/TA_lag);
S1= (sales/TA_lag);
S2= (delta_sales/TA_lag);
S3= (delta_sales_lag/TA_lag);
S4= (sales_lag/TA_lag);
PRODa= (PROD/TA_lag);
EXPENa= (EXPEN/TA_lag);
run;
then i tried to change my way by using this statement directly without creating var_lag
as follows
data attempt; set erm_var;
cshflo=csfo/lag(Total_assets);
TA1=(1/lag(Total_assets));
S1= (sales/lag(Total_assets));
S2= (delta_sales/lag(Total_assets));
S3= (delta_sales_lag/lag(Total_assets));
S4= (sales_lag/lag(Total_assets));
PRODa= (PROD/lag(Total_assets));
EXPENa= (EXPEN/lag(Total_assets));
run;
of course by first way there were a lot of missing value while in the second way less than, so please which way is correct
Using one variable instead of multiple lag() calls renders the same result:
data test1;
set sashelp.class;
s1 = lag(age);
s2 = 1/lag(age);
s3 = weight/lag(age);
run;
data test2;
set sashelp.class;
agelag = lag(age);
s1 = agelag;
s2 = 1/agelag;
s3 = weight/agelag;
drop agelag;
run;
proc compare
base=test1
compare=test2
criterion=0.00001
method=RELATIVE
out=comp(label="Compare Data for TEST1 and TEST2")
outstats=stat(label="Compare Data Summary Statistics for TEST1 and TEST2")
outnoequal
maxprint=50
;
var Name Sex Age Height Weight s1 s2 s3;
with Name Sex Age Height Weight s1 s2 s3;
run;
Dataset comp will be empty, meaning both datasets are identical.
Using one variable instead of multiple lag() calls renders the same result:
data test1;
set sashelp.class;
s1 = lag(age);
s2 = 1/lag(age);
s3 = weight/lag(age);
run;
data test2;
set sashelp.class;
agelag = lag(age);
s1 = agelag;
s2 = 1/agelag;
s3 = weight/agelag;
drop agelag;
run;
proc compare
base=test1
compare=test2
criterion=0.00001
method=RELATIVE
out=comp(label="Compare Data for TEST1 and TEST2")
outstats=stat(label="Compare Data Summary Statistics for TEST1 and TEST2")
outnoequal
maxprint=50
;
var Name Sex Age Height Weight s1 s2 s3;
with Name Sex Age Height Weight s1 s2 s3;
run;
Dataset comp will be empty, meaning both datasets are identical.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.