KoalaKeeper
KoalaKeeper

Reputation: 41

Selecting SAS column by the character string within a row observation

I have a table(A) with rows that have character strings that should match column names. I'm trying to match the name within the row observation with the corresponding column of the table A and check the values within that column and give a T/F flag.

for example if the row observation is 'A-3', i can go into the 'A-3' column and check that corresponding row for a value.

Upvotes: 1

Views: 233

Answers (1)

Reeza
Reeza

Reputation: 21274

Use VVALUEX() as long as you're ok with everything coming back as characters. Link to VVALUEX documentation

A-3 isn't a valid SAS variable name, but assuming it is you'd refer to it as 'A-3'n.

   data want;
      set have;
      x = vvaluex('A-3'n);
      x1 = vvaluex(A_3);    
   run;

Upvotes: 2

Related Questions