Dear all,
I am having trouble transposing a row of data and putting that data into one variable, something similar to xpose and sxpose, but not exactly the same.
Here is what I need help with: I have a dataset like below:
I want to have the row data (one, two, three and four) in a variable. Something like this:
I cannot use sxpose and xpose, because it will mess other data.
So, I was trying to use loop to transpose the row into column. I have tried looping various ways, for instance the following without success:
Would someone be able to help?
Thanks.
Masood
I am having trouble transposing a row of data and putting that data into one variable, something similar to xpose and sxpose, but not exactly the same.
Here is what I need help with: I have a dataset like below:
Code:
input str3(var1 var2) str5 var3 str4 var4 str5 var5 "one" "two" "three" "four" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" end
Code:
"one" "two" "three" "four" "one" "" "" "" "" "two" "" "" "" "" "three" "" "" "" "" "four"
So, I was trying to use loop to transpose the row into column. I have tried looping various ways, for instance the following without success:
Code:
foreach i of varlist var1-var4 { forv n=1/4 { replace var=`i'[1] in `n' if var=="" } }
Thanks.
Masood
Comment