Create indicator variables in SPSS using loops -


i trying create indicator variables in spss using loop.

i want create 17 new variables aba(1-17) take value of 1 if ba(1-17) equals 1. trying like:

vector aba(17). loop #i = 1 17. if(ba(#i)=1) aba(#i) = 1. end loop. execute. 

this, unfortunately, creates variables missing values. above code need small tweak or more efficient way accomplish creating variables?

i believe need define set of ba variables vectors before can reference them such in code. try:

vector aba(17) /ba=ba1 ba17. loop #i = 1 17. if(ba(#i)=1) aba(#i) = 1. end loop. execute. 

note, given ba variables exist in dataset cannot reference them vector ba(17). instead must use vector ba=ba1 ba17. if not in order in datafile have them in order using add files file re-arrange variable ordering.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -