BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
eugeniothierry
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19
 

@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;

Capture.PNG

View solution in original post

6 REPLIES 6
Reeza
Super User
Conveniently, TRANSPOSE often does this for you. So depending on how you do your transpose that may be one way.


Or can you use PROC REPORT to create the report with ODS EXCEL?
data_null__
Jade | Level 19
 

@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;

Capture.PNG

Tom
Super User Tom
Super User

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

data_null__
Jade | Level 19

When right aligned in $200 it can be confusing.  I could have used a LEFT();

Ksharp
Super User
But It is not good for BIG table and not efficient .
eugeniothierry
Fluorite | Level 6
Thank you, when I transposed my data, numeric variables showed as "..." in SAS egp.
So I assumed something didn't work properly. I was wrong.
I will try proc report as I rarely use it.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 818 views
  • 6 likes
  • 5 in conversation