I have a variable whose values are a comma delimited text string:
Each value in the text string represents an associated beta value in another sas data set. So 3,5 represents B3 & B5 found in dataset PARMS. I need a method of
a) parsing through the values in the string (I chose an array)
b) then associating those values with the beta values in another dataset
(I was thinking an array of macro variables)
The structure of the beta data set includes a beta variable for every B(i), e.g. B1=value B2=value. It is a single row of data. There are currently a few additional columns that include _TYPE_, etc.
Since I want to refer to the value of each B(i) I thought an array of macro variables would do the trick. I could use some assistance and suggestions w.r.t creating the array of string values....but am more in need of assistance w.r.t. referencing actual values of B(i), how and when do I call them.
Am I doing something in multiple steps that can be accomplished going directly from list to beta value....I think the macro array is necessary but would like confirmation.
A DATA step approach to parse out the input, creating some max number of B1 through Bnn SAS variables (not macro). Suggest calling these variable some different prefix, so that you can correlate them back to the Bnn variables in your beta dataset. Parsing can use DO UNTIL( = ' '); END; or some DO / END technique, keeping track of the max suffix value thus far (as a RETAIN variable since you have multiple input records).
Sounds like a straightforward SAS (non macro language) task to me, however you might benefit from a macro variable to set the maximum SAS Bnn or new_Bnn var suffix (the "nn" portion).
Something like this maybe.... but I don't see how to accomplish the sequential variable names without a macro, the number will vary by group so I don't want to explicitly list them. What am I missing?
by ists tosts;
do i=1 to 5;
do until (last.ists);
do until (last.tsts);
do while n < maxcnt;
**this is where I'm stuck where abeta(n) is abeta1 - abeta(maxcnt -1);
I'm going to rephrase my question it's more of a conceptual question.
I have a variable whose value is a comma delimited text string. The text string itself it is a series of values. The number of values in the text string varies from record to record. The number of values in each text string is identified by another variable mxcnt, (mxcnt -1) has been defined as the the number of values in the text string.
Ultimately I will want to use these values 3,5,7 to refer to a variable in another table(single vector of b1 variables and their relative values)namely b3,b5,b7 and return the value of the respective b variable.
What is the best approach, if in the long run I'm using the values to reference variables in another table.
you have run-time information in a variable (in I presume, more than one row) of a data-set. So, why try to solve the lookup with compile-time information like macro variables?
The classic solutions would be either an indexed set statement, or an informat lookup (well, you have a string and want the corresponding numeric value from another table).
Since SAS9 the new alternative to consider is a hash table lookup. Over formats and informats, hash tables have the advantage of indexing on multiple keys and can return more than one value, and all these keys and data can be of mixed data-types.
Each of these alternative techniques will feature among the Samples you'll find searchable in the http://support.sas.com site.
Good luck as you discover the wealth of ideas provided there.