Hello,
I was trying to understand how memory utilization is done in SAS. SASHELP.CLASS dataset has fize size of 128KB and when trying to print this dataset (PROC PRINT) it is utilizing ~843KB, almost 6 time the its file size. Where as proc sql select utilizing ~3248KB.
1) Why 6 times more?
2) Can we reduce memory usage?
options fullstimer;
proc sql;
create table test as
select Libname,memname,filesize format=sizekmg.
from dictionary.tables
where libname='SASHELP' and memname='CLASS';
quit;
proc print data=sashelp.class noobs;
run;
proc sql;
select * from sashelp.class;
quit;
23 options fullstimer; 24 25 proc print data=sashelp.class noobs; 26 run; NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: PROCEDURE PRINT used (Total process time): real time 0.02 seconds user cpu time 0.01 seconds system cpu time 0.00 seconds memory 845.78k OS Memory 15956.00k Timestamp 01/03/2019 12:11:05 PM Step Count 12 Switch Count 24 27 28 proc sql; 29 select * from sashelp.class; 30 quit; NOTE: PROCEDURE SQL used (Total process time): real time 0.02 seconds user cpu time 0.01 seconds system cpu time 0.00 seconds memory 3249.12k OS Memory 19032.00k Timestamp 01/03/2019 12:11:05 PM Step Count 13 Switch Count 24
Hello @SuryaKiran
Bench marking performance on small data sets can be tricky. Look at the results I have got. Each Re-run gave me a different result.
24 options fullstimer; 25 26 27 proc print data=sashelp.class noobs; 28 run; NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: PROCEDURE PRINT used (Total process time): real time 0.01 seconds user cpu time 0.00 seconds system cpu time 0.00 seconds memory 602.37k OS Memory 16424.00k Timestamp 01/03/2019 11:47:33 AM Page Faults 0 Page Reclaims 8 Page Swaps 0 Voluntary Context Switches 4 Involuntary Context Switches 4 Block Input Operations 0 Block Output Operations 0 29 30 proc sql; 31 select * from sashelp.class; 32 quit; NOTE: PROCEDURE SQL used (Total process time): real time 0.12 seconds user cpu time 0.01 seconds system cpu time 0.00 seconds memory 303.31k OS Memory 16424.00k Timestamp 01/03/2019 11:47:33 AM 2 The SAS System 09:57 Thursday, January 3, 2019 Page Faults 0 Page Reclaims 2 Page Swaps 0 Voluntary Context Switches 25 Involuntary Context Switches 7 Block Input Operations 0 Block Output Operations 0
@r_behata I'm aware that it varies, but my question is why the memory size is very high than its file size?
Part of that is the memory requirements for holding tables in memory while building them for display in HTML/RTF/PDF other destination.
HTML default destination for results open 184 proc print data=sashelp.class; NOTE: Writing HTML Body file: sashtml3.htm 185 run; NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: PROCEDURE PRINT used (Total process time): real time 0.64 seconds user cpu time 0.21 seconds system cpu time 0.26 seconds memory 6588.76k OS Memory 22772.00k Timestamp 01/03/2019 02:57:54 PM Step Count 25 Switch Count 0 186 ods html close; 187 ods listing; 188 %put HTML Closed and List output used.; HTML Closed and List output used. 189 proc print data=sashelp.class; 190 run; NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds user cpu time 0.00 seconds system cpu time 0.00 seconds memory 360.37k OS Memory 21492.00k Timestamp 01/03/2019 02:57:54 PM Step Count 26 Switch Count 0 191 ods listing close;
Different destinations and style options actually used will affect the numbers.
Don't forget the SAS procedure you are using takes up memory too. PROC PRINT is a relatively simple procedure so takes up less memory than PROC SQL which is much more complex with a lot more functionality.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.