Hi,
I need to recreate an excel report, moving every formula to SAS.
The final form is not in a Dataset structure, variables names are on the left.
I will need to transpose everything.
Is there a way to convert easily the whole table to Character?
I mean without a macro function or a list of put().
Thank you in advance
@Reeza wrote:
Conveniently, TRANSPOSE often does this for you. So depending on how you do your transpose that may be one way.
When the VAR statement contains numeric variables and at least one character variable all number variables are converted to their FORMATTED values. You will see this message.
NOTE: Numeric variables in the input data set will be converted to character in the output data set.
proc transpose data=sashelp.class out=allchar1;
var _all_;
run;
proc transpose data=allchar1 out=allchar2(drop=_name_);
var col:;
run;
proc contents varnum;
proc print;
run;
@Reeza wrote:
Conveniently, TRANSPOSE often does this for you. So depending on how you do your transpose that may be one way.
When the VAR statement contains numeric variables and at least one character variable all number variables are converted to their FORMATTED values. You will see this message.
NOTE: Numeric variables in the input data set will be converted to character in the output data set.
proc transpose data=sashelp.class out=allchar1;
var _all_;
run;
proc transpose data=allchar1 out=allchar2(drop=_name_);
var col:;
run;
proc contents varnum;
proc print;
run;
One thing you cannot tell from looking at that ODS output is that the values are right aligned in the character fields. If you look at the POT (plain old text) output instead it is more visible.
Obs Name Sex Age Height Weight 1 Alfred M 14 69 112.5 2 Alice F 13 56.5 84 3 Barbara F 13 65.3 98 4 Carol F 14 62.8 102.5 5 Henry M 14 63.5 102.5 6 James M 12 57.3 83 7 Jane F 12 59.8 84.5 8 Janet F 15 62.5 112.5 9 Jeffrey M 13 62.5 84 10 John M 12 59 99.5 11 Joyce F 11 51.3 50.5 12 Judy F 14 64.3 90 13 Louise F 12 56.3 77 14 Mary F 15 66.5 112 15 Philip M 16 72 150 16 Robert M 12 64.8 128 17 Ronald M 15 67 133 18 Thomas M 11 57.5 85 19 William M 15 66.5 112
When right aligned in $200 it can be confusing. I could have used a LEFT();
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.