Is the below an Issue or my lack of understanding: Sum statement with RETAIN vs NO RETAIN handling missing values
data _null_;
retain k;
b=.;
k+b;
put k=;
run;
data _null_;
/* retain k;*/
b=.;
k+b;
put k=;
run;
Can somebody explain and help me why the difference in the results of K in the above 2 programs plz? Thank you in advance!
LOG-
70
71 data _null_;
72 retain k;
73 b=.;
74 k+b;
75 put k=;
76 run;
k=.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
77
78
79 data _null_;
80 /* retain k;*/
81 b=.;
82 k+b;
83 put k=;
84 run;
k=0
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
@novinosrin wrote:
Is the below an Issue or my lack of understanding: Sum statement with RETAIN vs NO RETAIN handling missing values
data _null_; retain k; b=.; k+b; put k=; run; data _null_; /* retain k;*/ b=.; k+b; put k=; run;
Can somebody explain and help me why the difference in the results of K in the above 2 programs plz? Thank you in advance!
LOG-
70 71 data _null_; 72 retain k; 73 b=.; 74 k+b; 75 put k=; 76 run; k=. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 77 78 79 data _null_; 80 /* retain k;*/ 81 b=.; 82 k+b; 83 put k=; 84 run; k=0 NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
In your first data step you RETAIN K and implicitly initialize to missing.
@novinosrin wrote:
Is the below an Issue or my lack of understanding: Sum statement with RETAIN vs NO RETAIN handling missing values
data _null_; retain k; b=.; k+b; put k=; run; data _null_; /* retain k;*/ b=.; k+b; put k=; run;
Can somebody explain and help me why the difference in the results of K in the above 2 programs plz? Thank you in advance!
LOG-
70 71 data _null_; 72 retain k; 73 b=.; 74 k+b; 75 put k=; 76 run; k=. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 77 78 79 data _null_; 80 /* retain k;*/ 81 b=.; 82 k+b; 83 put k=; 84 run; k=0 NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
In your first data step you RETAIN K and implicitly initialize to missing.
Right, got it sorry my bad!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.