Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine the length of an array?

Tags:

arrays

sas

If I dont know the exact length of an array after a transpose, is there a way to output it? or to use it, without manually looking through the output data? For example, if I transpose on number of pills dispensed, but that number is variable for each 'id' and then I want to specify that array in a regression, is there a way to do it without finding the value via manual visual inspection?

PROC PHREG DATA=...;
ARRAY start{*} start1-start????;
DO I=1 TO ?????;
IF  start{I}<t2event THEN var=1;
END;
MODEL .........

As a corollary if I know that its less than say, 100, and I specify 100, would there be any consequence? Thanks!

like image 954
Rainmaker Avatar asked May 28 '16 15:05

Rainmaker


People also ask

How do you find the length of an array?

Using sizeof() function to Find Array Length in C++ Hence, if we simply divide the size of the array by the size acquired by each element of the same, we can get the total number of elements present in the array.

What is the length of array?

Basically, the length of an array is the total number of the elements which is contained by all the dimensions of that array. Property Value: This property returns the total number of elements in all the dimensions of the Array. It can also return zero if there are no elements in the array.

How do you find the length of an array in Java?

To get the size of a Java array, you use the length property. To get the size of an ArrayList, you use the size() method. Know the difference between the Java array length and the String's length() method.


1 Answers

The DIM() function returns the dimensions of an array. You can use the : suffix to make a variable list of names that start with the same letters.

 ARRAY start{*} start: ;
 DO I=1 TO dim(start);
like image 95
Tom Avatar answered Sep 29 '22 11:09

Tom