0

I have a SPSS dataset with 3 columns ("companies", "date", "return") like this:

Initial Dataset

Now I would like to transform it so that only dates show up in a row and each company return for a given date is in a separate column, like this:

Final Dataset

Is there an easy way to do that in either SPSS or R?

Thanks for the help!

fl4t1
  • 1
  • 1
    Welcome to Stack Overflow. Please avoid posting pictures of data. Use `dput` instead to make reproducible example(s). [Give this link](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) a read. Thanks – Sotos May 05 '16 at 11:38
  • You could use `dcast` from `reshape2` – akrun May 05 '16 at 11:40
  • i.e. `dcast(df1, date~companies, value.var= "return")` – akrun May 05 '16 at 11:46

1 Answers1

0

In SPSS:

sort cases by date companies.
casestovars /id=date /index=companies /separator="_".
eli-k
  • 10,898
  • 11
  • 40
  • 44