@westbestern wrote:
These are all character variables. I want to run a bivariate analysis on the association between insurance variables and PrEP usage without going through all the insurances individually. Basically, does have insurance influence PrEP usage? There are 11 insurance variables.
I would do something similar to
data want;
set have;
array ins(*) <list the names of your insurance variables here>;
have_ins = (index(cats(of ins(*)),'1')>0);
end;
The CATS function concatenates all the values of the variables in the array, the Index function returns the first position of the character 1, if present or 0 other wise. SAS will return a numeric 1 for that index value greater than 0 or 0 otherwise.
Suggestion for future stuff. If your variables are dichotomous, such as "has this characteristic/does not have" then coding them as 1/0 (have, don't have; true/false; yes/no) numeric variables is more flexible than character.
Max(of array(*)) would return 1 if any were 1(present/true whatever) or 0 if none were.
Sum(of array(*)) tells you how many had a 1
Mean(of array(*)) tells you the percent of 1 were present (.8 = 80%)
Min(of array(*)) =1 tells you all the values were 1
Range(of array(*)) =1 tells you at least one value was 0 and at least one was 1, a range of 0 tells you all the values were the same.
With character values a tad more coding would be needed for most of these, especially percentages.
... View more