BookmarkSubscribeRSS Feed
Shomo_olongus
Calcite | Level 5

Please can some help me to write an array to select the first 4 trt (trt1 to trt4) into block 1, second 4 trt (trt5-trt8) to block 2, third 4trt (trt9-trt12) to block 3 and fourth 4trt (trt13 to trt16) to block 4?

 

%let N=100;
data generate;
call streaminit(0);
 do i=1 to &N;
 trt1 = rand("Normal");
 trt2 = rand("Normal",1,2);
 trt3 = rand("Normal",9,8);
 trt4 = rand("Normal",3,5);
 trt5 = rand("Normal",2,12);
 trt6 = rand("Normal",1,6);
 trt7 = rand("Normal");
 trt8 = rand("Normal",3,3);
 trt9 = rand("Normal",4,6);
 trt10 = rand("Normal",2,3);
 trt11 = rand("Normal",0,3);
 trt12 = rand("Normal");
 trt13 = rand("Normal",4,2);
 trt14 = rand("Normal",3,1);
 trt15 = rand("Normal",0,9);
 trt16 = rand("Normal");s
 output;
 end;
run;

2 REPLIES 2
ballardw
Super User

Can you show what you would expect the output data set to look like?

 

It might help to provide a few records of actual values, may be 5 to 10 rows, for your treatment variables and then what the data would look like after the assignment.

 

As it is, it is not clear whether you expect to have one block variable with 4 levels  or 4 variables much less what the associated treatment variables would then look like.

Shomo_olongus
Calcite | Level 5

Please I expect the data to look like this . 

 

Block 1

 

Trt1      Trt2        Trt3      Trt4          

   1           1          1           1          

   2           2          2           2

   3           3          3           3        

   .            .            .            .  

   .            .            .            .

   .            .            .            .        

 100       100        100      100            

 

Block 2

 

Trt5      Trt6        Trt7      Trt8          

   1           1          1           1          

   2           2          2           2

   3           3          3           3        

   .            .            .            .  

   .            .            .            .

   .            .            .            .        

 100       100        100      100        

 

Block 3

 

Trt9      Trt10      Trt11      Trt12          

   1           1          1           1          

   2           2          2           2

   3           3          3           3        

   .            .            .            .  

   .            .            .            .

   .            .            .            .        

 100       100        100      100        

 

 

Block 4

 

Trt13      Trt14     Trt15      Trt16        

   1           1          1           1          

   2           2          2           2

   3           3          3           3        

   .            .            .            .  

   .            .            .            .

   .            .            .            .        

 100       100        100      100        

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 575 views
  • 0 likes
  • 2 in conversation