0
votes

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!

1
Welcome to Stack Overflow. Please avoid posting pictures of data. Use dput instead to make reproducible example(s). Give this link a read. Thanks - Sotos
You could use dcast from reshape2 - akrun
i.e. dcast(df1, date~companies, value.var= "return") - akrun

1 Answers

0
votes

In SPSS:

sort cases by date companies.
casestovars /id=date /index=companies /separator="_".