Desktop productivity for business analysts and programmers

Transpose limitation

Frequent Contributor
Posts: 97

Transpose limitation


I have a dataset



I want to show an output from EG using transpose as shown below


Pls help. Ignore the lines it was used just to show output

Query is same as posted inᯉ

Can we do it using the Transpose task of EG. It is possible using one cloumn like quantity but not possible if there are multiple columns.
Posts: 9,424

Re: Transpose limitation

Do you want a REPORT or a DATA set? If you want a REPORT, then I would recommend the use of PROC TABULATE. If you want a DATA set, then I would recommend either PROC TRANSPOSE or a DATA step program. It looks to me like you want ALL the rows for the days in JAN to be added and ALL the rows for the days in FEB to be added up.

Examine the file has a lot of DETAIL records for Actual and Predicted Sales. I can produce this REPORT table using PROC TABULATE (or the Summary Table task in EG):
TABULATE Summary Report

| | Month | |
| +-----------------+-----------------+-----------------+ |
| | Jan | Feb | Mar | Total |
| +--------+--------+--------+--------+--------+--------+--------+--------+
| | Actual |Predict | Actual |Predict | Actual |Predict | Actual |Predict |
|Product | | | | | | | | |
|type | | | | | | | | |
+---------+ | | | | | | | |
|FURNITURE| 23,843| 28,445| 23,348| 24,397| 22,585| 23,560| 69,776| 76,402|
|OFFICE | 39,674| 36,653| 33,949| 34,263| 35,634| 38,883| 109,257| 109,799|
|Total | 63,517| 65,098| 57,297| 58,660| 58,219| 62,443| 179,033| 186,201|


Where I have MONTH, you would have your date variable (formatted with MONNAME3. probably).
Where I have ACTUAL, you would have Quantity.
Where I have PREDICT, you would have Value.
Where I have PRODTYPE, you would have Order Type.
I put TOTAL at the bottom of all the ROW and TOTAL at the end of all the COLUMNS -- you could put it at one place or the other or leave it at both.
What does the number 23,843 represent?? It is the summing up of ACTUAL for all the rows where PRODTYPE=FURNITURE and month (formatted with MONNAME3.) = JAN.

You CAN produce this kind of REPORT using the Summary Table task in Enterprise Guide. Or you could use PROC TABULATE code.

For more help with the difference between PROC TRANSPOSE to create a data set and the Summary Table task to create a report with the months going across the columns, you might consider contacting Tech Support. The PROC TABULATE code that produced the above REPORT is shown below (I used the WHERE clause as a convenience to get only 3 months of data.).


proc tabulate data=sashelp.prdsale format=comma8.;
title 'TABULATE Summary Report';
where quarter = 1;
var actual predict;
class month prodtype;
table prodtype all,
month*(actual predict) all*(actual predict)
keylabel sum=' '
label actual = 'Actual'
predict = 'Predict';
Not applicable
Posts: 0

Re: Transpose limitation

Posted in reply to Cynthia_sas

Thanx for the solution.
But how to supress dot(.) values in the numeric field .
for example:
In your report output which you mentioned,
If suppose there is no actual or predict value of product type furniture in the month jan then it will display as '.' (dot) .
Can you tell me any option so taht i can substitute 0 instead of '.'

Posts: 9,424

Re: Transpose limitation

Posted in reply to deleted_user
Look in the documentation for the SAS System Option named MISSING. These are only some possibilities for the MISSING OPTION:

missing=' '
missing = 'z'
missing = '0'

To find a list of the SAS System Options and see the specific syntax of the SAS OPTIONS statement, look in the documentation for the topic:
SAS System Options by Category

PROC TABULATE has an alternative way to represent missing values for calculated numeric values. For example, what if your store did not open until February -- due to unseen problems. You might have a predicted amount for January sales, but if the store was not open, there would not be any value OTHER than missing possible for actual sales. In that case, you might want to show "N/A" or "not applicable" or "no sales" in the calculated cell for January. To learn more about using this TABULATE-specific method, you can investigate the "MISSTEXT" option for PROC TABULATE.

Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation