Buongiorno a tutti,
devo creare una colonna che contenga la differenza tra un dato ed il suo precedente, ho provato con "retain" ma non riesco, potete aiutarmi?
Grazie ·
·
Buongiorno,
Usa la funzione DIF.
data Have;
input RET_TOT;
datalines;
154
194
681
186
078
133
522
943
430
733
;
data Want;
set Have;
retain Differenza;
Differenza = dif(RET_TOT);
if Differenza = . then Differenza = 0;
run;
proc print; run;
Buongiorno,
Usa la funzione DIF.
data Have;
input RET_TOT;
datalines;
154
194
681
186
078
133
522
943
430
733
;
data Want;
set Have;
retain Differenza;
Differenza = dif(RET_TOT);
if Differenza = . then Differenza = 0;
run;
proc print; run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.