BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tecla1
Quartz | Level 8

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 ·

Tecla1_0-1639656144946.png

 

 

 

·

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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;

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

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;
Tecla1
Quartz | Level 8
Many Tnks!!! IT's more symple than I could think.
Have a nice afternoon!!!
Tecla

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1238 views
  • 3 likes
  • 2 in conversation