/***************************************************************************************************************** SAS file name: read_write_array.sas File location: __________________________________________________________________________________________________________________ Purpose: To demonstrate how to use the PROC FCMP special Read_Array and Write_Array Functions in SAS. Author: Peter Clemmensen Creation Date: 01/11/2019 This program supports the blog post "Using the SAS Read_Array and Write_Array Fundtions in PROC FCMP" on SASnrd.com *****************************************************************************************************************/ /* Read_Array Function */ data in; input a b c; datalines; 1 2 3 4 5 6 7 8 9 ; proc fcmp; array x{3, 3} / nosymbols; rc=read_array('in',x); put x=; quit; /* The array is dynamic and adapts to the input data set */ proc fcmp; array x{1} / nosymbols; rc=read_array('in',x); dim1=dim(x, 1); dim2=dim(x, 2); put dim1= / dim2=; quit; /* Read only specified columns */ proc fcmp; array x{1} / nosymbols; rc=read_array('in',x, 'a', 'b'); put x=; quit; /* Write_Array Function */ proc fcmp; array x{3, 3} / nosymbols ( 1 2 3, 4 5 6, 7 8 9 ); rc=write_array('out', x); quit; /* Transposing a matrix */ data in; input a b c; datalines; 1 2 3 4 5 6 7 8 9 ; proc fcmp; array x {3, 3} / nosymbols; array y{3, 3} / nosymbols; rc=read_array('in',x); call transpose(x, y); rc=write_array('out', y, 'a', 'b', 'c'); quit;