# Demo entry 6658623

sas

Submitted by anonymous on Nov 08, 2017 at 08:25
Language: SAS. Code size: 2.5 kB.

```/*
SAS ',' && matlab ';'
*/
data class;
set sashelp.class;
run;

/**/
proc iml;
a = {1 1 2,
3 4 4,
5 5 6};
b = {[2]1 2,
3 [2]4,
[2]5 6};

deta = det(a);

ab = a||b;
a_b = a//b;

a_m_b = a*b;
a_mp_b = a#b;
a_d_b = a/b;
c = a@b;

at = a`;
test = inv(a);
e = a*test;

print a, b , ab, a_b, a_m_b, a_mp_b, a_d_b, c, at, test;
print e;
print a b c;

quit;

/**/
proc iml;
a = {1 1 2,
3 4 4,
5 5 6};

a_sum_r = a[,+];
a_sum_c = a[+,];
a_mean_r = a[,:];
a_mean_c = a[:,];
a_max_r = a[,<>];
a_min_c = a[><,];
print a, a_sum_r a_sum_c, a_mean_r a_mean_c, a_max_r a_min_c;
quit;

/**/
proc iml;
use class;
read all var{name age height weight};

/* create var */
height_m = 0.0254*height;
weight_kg = 0.453592*weight;
BMI = (0.453592*weight)/(0.0254*height)##2; /* PAT: use '##' instead of '**' */

/* create matrix */
new_data = age|| height_m || weight_kg || BMI;
*print new_data;

create class_BMI from new_data[colname={'age' 'height_m' 'weight_kg' 'BMI'}]; * open;
append from new_data; * write;
close class_BMI;
quit;
proc print;run;

/**/
%macro plot_norm_density(mu=, sigma=);
proc iml;
* mu = 10;
* sigma = 1;
x = -1000:1000;
x = x/100;
x = x+&mu.;
x = x`;

y = 1/(sqrt(2*constant('pi'))*&sigma.) * exp( -1/2*((x-&mu.)/&sigma.)##2 );
norm_matrix = x||y;

create norm_data from norm_matrix[colname={'x', 'y'}];
append from norm_matrix;
close norm_data;

quit;

symbol v=point i=spline;
proc gplot data=Norm_data;
plot y*x;
run;
symbol;
%mend plot_norm_density;

%plot_norm_density(mu=10, sigma=2);

/*

proc iml;
mu = 10;
sigma = 1;
x = -1000:1000;
x = x/100;
x = x+mu;
x = x`;
* y = exp( -1/2*((x-mu)/sigma)##2 );
* test_pi = constant('pi');
* test = 1/(sqrt(2*constant('pi'))*sigma);
y = 1/(sqrt(2*constant('pi'))*sigma) * exp( -1/2*((x-mu)/sigma)##2 );
norm_matrix = x||y;
* print norm_matrix;

create norm_data from norm_matrix[colname={'x', 'y'}];
append from norm_matrix;
close norm_data;

quit;

symbol v=point i=spline;
proc gplot data=Norm_data;
plot y*x;
run;
symbol;

*/

proc iml;
* mu = 10;
* sigma = 1;
x = -1000:1000;
x = x/100;

x = x`;
print x;
quit;

/* test */
data n;
length x 20. y 20. yy 20.;
x = constant('pi');
y = constant('e');
yy = exp(1);
run;
```

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.