1
votes

I have a SAS dataset that I want to transpose with both character and numerical variables. Only interval and group are character variables, the rest are numerical variables. However, proc transpose converts all of the variables into character variables. How can I modify the below program so that numerical variables remain as numerical and character variables as character after the transpose procedure? Thank you.

proc transpose data=sourceh.test out=sourceh.test2;
var interval group cap rank volatility correlation significance;
run;
1
You can't have different types in the same column.Reeza
When you transpose a long dataset to wide, you create a column in the new dataset for every row in the original dataset. As @Reeza points out, this means you'll get a mixture of numeric and character values in each column, therefore the variable type has to be character. Perhaps if you post some sample data and what you want the result to look like, it may show something different to a standard transpose.Longfish
I understand the logic now, thanks @Reeza and Longfish. I converted my char variables into numerical variables, and that solved my problem for now. Thanks.Betsy B

1 Answers

3
votes

You can do it in two steps.

proc transpose data=sourceh.test out=nums prefix=num;
   var _numeric_;
   run;
proc transpose data=sourceh.test out=char prefix=char;
   var _character_;
   run;

FYI: the conversion of character to numeric that you are getting now can be a useful feature, I call it en masse VVALUE.