BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Lulus
Obsidian | Level 7
Header 1Header 2Header 3
1
0.21
0.50.91
0.800.28

So I have something like this but it's a very big one (100K*100K).

Header 1Header 2Header 3
10.20.5
0.210.9
0.50.91

I hope to get the spces all filled up with a correlation or simmilarity whatever becomes

I know proc iml can do this quickly but my sas just doesn't have proc iml comes with it.

Please let me know anyway I can solve the problem.

I aprpeciate!!

-Sarah

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

100k variables is a lot!  This works for 10,000 variables and doesn't take too long.  I tried it with 100,000 but did not want to wait for it to finish.

This method is simple flip the data over, so that you get an upper trianglar.  Then update the lower with the upper.  Requires an observation index variable (_obs_).

data head;
   array header[10000];
   do _obs_ = 1 to dim(header);
      do i = 1 to _obs_;
         if i = _obs_ then header=1;
        
else header=ranuni(1);
         end;
     
output;
     
end;
  
run;

proc transpose data=head out=head2 prefix=header;
   copy _obs_;
   var header:;
   run;

data head3;
   update head head2;
   by _obs_;
   run;

View solution in original post

3 REPLIES 3
data_null__
Jade | Level 19

100k variables is a lot!  This works for 10,000 variables and doesn't take too long.  I tried it with 100,000 but did not want to wait for it to finish.

This method is simple flip the data over, so that you get an upper trianglar.  Then update the lower with the upper.  Requires an observation index variable (_obs_).

data head;
   array header[10000];
   do _obs_ = 1 to dim(header);
      do i = 1 to _obs_;
         if i = _obs_ then header=1;
        
else header=ranuni(1);
         end;
     
output;
     
end;
  
run;

proc transpose data=head out=head2 prefix=header;
   copy _obs_;
   var header:;
   run;

data head3;
   update head head2;
   by _obs_;
   run;
FriedEgg
SAS Employee

I do not think a 100k X 100k matrix will be possible to do this way, I think it tops out somewhere above 16k X 16k.  Not sure if this is some limit on FCMP.

proc fcmp;

array x[10000,10000] /nosymbols;

t=time();

/* fill lower triangle */

do a=1 to 10000;

  do b=1 to a;

   x[a,b]=1 ++ a +- b ;

  end;

end;

d=time()-t;

put 'fill=' d 'seconds';

t=time();

/* fill upper triangle */

do a=1 to 10000 by 1;

  do b=10000 to a by +-1;

   x[a,b]=x[b,a];

  end;

end;

d=time()-t;

put 'transpose=' d 'seconds';

t=time();

rc=write_array('all',x);

d=time()-t;

put 'write=' d 'seconds';

run;

fill= 1.0461549759 seconds

transpose= 2.3460171223 seconds

write= 7.7724590302 seconds

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

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
  • 3 replies
  • 459 views
  • 3 likes
  • 3 in conversation