INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

colon modifier (:) in array value and underscore(_in) in array variable name

colon modifier (:) in array value and underscore(_in) in array variable name

(OP)
I am trying to understand the folowing piece of code:

data long (keep=icd9 icd10);
set cwalk_wide;
array _in(*) $ icd10:;
i=1;
do while (i le dim(_in));
if not missing(_in{i}) then do;
icd10=_in(i);
output;
i+1;
end;
else i=dim(_in)+1;
end;
run;

Could you please help me to understand what the above code does (particularly colon(:) and _in?

RE: colon modifier (:) in array value and underscore(_in) in array variable name

_in(*) is the name of the Array with the '*' as the number of vars in the Array. Using the asterisk allows the user to add vars to the Array dynamically. This way the programmer doesnt have to limit the Array width to a specific number of vars.

Ex.

CODE

Array _in(4) x1 x2 x3 x4; 
In the above Array there are exactly 4 vars. In any loop that you set, you would need to set the max counter to 4.

Ex.

CODE

do i=1 to 4;
   your SAS code;
end; 

You can also have an array automatically grab all vars of the same type.
Ex.

CODE

Array myTest(*) _character_; 
This creates an Array myTest with all the Char variables in the dataset.
If we were to loop through the above array how would we know when to stop the loop? So we use the DIM() function.
ex.

CODE

do i=1 to dim(myTest);
  your SAS code;
end; 
As for the second part of the question ':' the colon is used to let SAS know the boundaries of the Array. Most of the time its never used and only in cases that have multi-dimension arrays.

I hope that this helps.

Klaz

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close