Good morning
I want to get an triangle matrix from a column like this:
data have;
input i column;
cards;
1 0.5
2 0.6
3 0.7
4 0.8
;
run;
data want;
input i col1 col2 col3 col4;
cards;
1 0.5 0.5 0.5 0.5
2 . 0.6 0.6 0.6
3 . . 0.7 0.7
4 . . . 0.8
;
run;
Any help is appreciated!
BR Dingdang
data have;
input i column;
cards;
1 0.5
2 0.6
3 0.7
4 0.8
;
run;
data want(drop=column j);
set have;
array col(*) col1-col4;
do j=_n_ to dim(col);
col(j)=column;
end;
run;
data have;
input i column;
cards;
1 0.5
2 0.6
3 0.7
4 0.8
;
run;
Data _NULL_;
Have_File=Open("have");
Obs=Attrn(Have_File,"Nobs");
Call SymputX ("Obs",Obs);
Run;
Data Want (Keep=i Col1-Col&Obs.);
Array Col Col1-Col&Obs.;
Set have;
Do j=1 To Dim(Col);
Col{j}=IfN(i le j,column,.);
End;
Run;
data have;
input i column;
cards;
1 0.5
2 0.6
3 0.7
4 0.8
;
run;
data want(drop=column j);
set have;
array col(*) col1-col4;
do j=_n_ to dim(col);
col(j)=column;
end;
run;
hi,
thank you for your code. this is exactly what I tried to do but failed. The other answers were also very good and interesting.
BR Dingdang
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.