This summarizes the results of the original code and responses received as of this date when executed against this table:
Data Set Name
LIBA.HAVE
Observations
500000
Member Type
DATA
Variables
50
Engine
V9
Indexes
1
Created
04/29/2024 09:02:45
Observation Length
400
Last Modified
04/29/2024 09:02:45
Deleted Observations
0
Protection
Compressed
NO
Data Set Type
Sorted
NO
Label
Data Representation
WINDOWS_64
Encoding
utf-8 Unicode (UTF-8)
Original Code:
proc sql;
update liba.have set country1='', country3='', pop1=., pop2=., pop1_date=.;
quit;
Results:
NOTE: PROCEDURE SQL used (Total process time):
real time 0.61 seconds
cpu time 0.23 seconds
So, .61 seconds was the time to beat!
@Tom's solution
data liba.have(index=(ID));
set liba.have;
call missing(of country1 country3 pop1 pop2 pop1_date);
run;
and @Ksharp's solution
proc sql;
alter table have
drop country1, country3,pop1,pop2,pop1_date
add country1 char(20), country3 char(3),pop1 num,pop2 num,pop1_date num;
quit;
tied for first place
real time 0.40 seconds
cpu time 0.20 seconds
With my solution:
data liba.have ;
modify liba.have;
call missing(country1, country3,pop1,pop2,pop1_date);
run;
coming in third,
real time 0.44 seconds
cpu time 0.32 seconds
and data_null__'s solution:
data liba.have (index=(ID));
if 0 then set liba.have;
set liba.have (drop=country1 country3 pop1 pop2 pop1_date);
run;
still beating the original post:
real time 0.58 seconds
cpu time 0.26 seconds
Of course, your mileage may vary depending on the size of your data.
... View more