07-26-2016 11:34 AM - edited 07-26-2016 11:35 AM
I'm trying to create new variables with an array statement that contain suffixes that match from a previously referenced array statement. This is my code:
DATA BLAH_F7; SET BLAH_F; ARRAY A[0:100]F_0--F_100; ARRAY P_[0:100]P_0--P_100; DO I=0 TO 100; P_(I)=A(I)/F_TOTAL; END; DROP I; RUN;
When I run this code, the array creates variables P_1 to P_101 instead of from P_0 to P_100, which is what I want (as I am trying to match to the F_0 to F_100 variables). Anyone have any suggestions? If this isn't possible using an array statement, I'd still be interested in hearing the simplest way to change these P_1 to P_101 variables to P_0 to P_100.
07-26-2016 11:43 AM
Thanks, this solution works. I guess P_0 needs to be explicitly stated since this is an array statement that isn't referencing any previously exisiting variables? I'm a little confused by why this works:
Array p_(0:100) p0 p1-p100;
but this doesn't work:
Array p_(0:100) p0-p100;
Thanks for your help!
07-26-2016 11:50 AM
Both of those should work.
The piece that doesn't work is the double dash. For SAS to interpret the double dash properly, the variables must already exist and cannot be created by the ARRAY statement.
Need further help from the community? Please ask a new question.