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

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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
  • 2101 views
  • 3 likes
  • 2 in conversation