Hello,
Thank you very much, I will try that. If i don't know the size of the array do i just use the ubound(array) syntax, is that correct? If you don't mind, can you show me an example of that. Thanks again.
When you define the array you define it like this
ARRAY JUNK{*} JUNK1 JUNK2 JUNK3;
I have never used an * when reading in - I always define a set space and have an error produced if it gets passed (your mileage may vary)
after that it gets more interesting. You can use the functions LBOUND, HBOUND and DIM
ex. Do I = LBOUND(Junk) to HBOUND(Junk)
or
Do I = 1 to DIM(Junk)
arrays are fun, but like in any other language if you right past what you have defined as the 'space' you can overwrite things and get unexpected errors. Don't forget that you have to define the array in each data step where you plan on using it (and on occasion you will need to RETAIN the whole array - for example I wanted to output 1 record with the info from twelve months - first time through I only got December... I had left off the retain of the array, so SAS zerod it out for each new observation).
Wow, thank you very much, you've helped me a great deal. Array's definitely are fun and very powerful too, they can make life real easy if coded properly Thanks again.
one more weird thing. SAS really stores the arrasy as seperate variables (so if I defined an array as WEIGHT{10} I would have WEIGHT1 WEIGHT2 WEIGHT3 WEIGHT4 WEIGHT5 WEIGHT6 WEIGHT7 WEIGHT8 WEIGHT9 WEIGHT10). I always found it a bit annoying that I did not get WEIGHT01 to WEIGHT10 so your deletes and things like that can be coded as WEIGHT1-WEIGHT10
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.