BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dingdang
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
stat_sas
Ammonite | Level 13

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;

View solution in original post

4 REPLIES 4
user24feb
Barite | Level 11

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_null__
Jade | Level 19
data haveV / view=haveV;
   set have nobs=nobs;
   do c = i to nobs;
      output;
     
end;
  
run;
proc transpose data=havev out=want2(drop=_name_);
   by i;
   var column;
   id c;
   run;
stat_sas
Ammonite | Level 13

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;

Dingdang
Fluorite | Level 6

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1119 views
  • 9 likes
  • 4 in conversation