How to pull the column name in to the data in SAS -


the table date variable name respect vol, want create new variable flag if variables having 1 pull date of variable name in flag column

  vol   31-dec-10   31-dec-11   31-dec-12   31-dec-13   31-dec-14   31-dec-15 109001  0   0   0   0   1   0 109002  0   0   1   0   0   0 109003  0   0   1   0   0   0 109004  0   0   0   1   0   0 109006  0   0   1   0   0   1 

output

 vol    31-dec-10   31-dec-11   31-dec-12   31-dec-13   31-dec-14   31-dec-15   flag 109001  0   0   0   0   1   0   31-dec-14 109002  0   0   1   0   0   0   31-dec-12 109003  0   0   1   0   0   0   31-dec-12 109004  0   0   0   1   0   0   31-dec-13 109006  0   0   1   0   0   1   31-dec-15 

you want use vlabel() function since column headings don't meet standard variable name requirements , i'm assuming they're labels. below example code put in data step, you'll have know actual variable names array declaration , replace date1--date99 them.

array mydates (*) date1--date99; on mydates;     if mydates = 1 flag = vlabel(mydates); end; 

the way loop written, leave date of rightmost occurrence of 1, seems consistent example in 19006 row.

see vname().


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -