BookmarkSubscribeRSS Feed
nidhi123
Calcite | Level 5
Hello,

I am writing a proc tabulate procedure. I need the same column two times. First without format then with format.

for example:
/*
proc tabulate data= Mydata missing order=data;

format var1 $var1form.;
format var2 $var2form.;

class year var1 var2 ;
var analyse;

table (var2='' * (var1='' all='Total') ), (year='' * analyse=''* {style=data_...etc ) *sum='';


by comp;
run;
*/


I need code of var1 and then text of var1 same for var2.

thanks
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Hi:
In your question, you say that you need "the same column two times". However, in your code, you only show the use of VAR1 and VAR2 one time each in the TABLE statement. For example, given this output table from TABULATE for 1 value of COMP:
[pre]
comp=CANADA

+------------------------------------------------+
| | 1993 | 1994 |
+----------------------+------------+------------+
|EAST |FURNITURE | 26950.00| 24370.00|
| +-----------+------------+------------+
| |OFFICE | 37180.00| 38985.00|
| +-----------+------------+------------+
| |Total | 64130.00| 63355.00|
+----------+-----------+------------+------------+
|WEST |FURNITURE | 21614.00| 24930.00|
| +-----------+------------+------------+
| |OFFICE | 35276.00| 37685.00|
| +-----------+------------+------------+
| |Total | 56890.00| 62615.00|
+------------------------------------------------+
[/pre]

Let's assume that EAST/WEST are values for VAR2 and that FURNITURE/OFFICE are values for VAR1. How do you envision using "the same column two times", given the above example????? Since you did not show your data, your desired output or your formats, it is hard to imagine what you want.

If you want to post output or sample data or program code to the forum, in order to protect > and < symbols, preserve code and output indention and to otherwise learn how to post special symbols to the forum, refer to this previous forum posting. It talks about the LT and GT symbols and also discusses how to emphasize code and how to surround code snippets and output results with [pre] and [/pre]
http://support.sas.com/forums/thread.jspa?messageID=27609毙

cynthia

The code that produced the above output is here:
[pre]
data mydata;
set sashelp.prdsale;
where country in ('CANADA', 'GERMANY');
comp = country;
var1 = prodtype;
var2 = region;
analyse = actual;
run;

options nocenter;
proc tabulate data= Mydata missing order=data
formchar='|-+-+++++-+';

class year var1 var2 ;
var analyse;

table (var2='' * (var1='' all='Total') ),
(year='' * analyse=''*sum='');
by comp;
run;
[/pre]
nidhi123
Calcite | Level 5
lets look at your example. Lets see we want to remove East from the left column, and put east as total. How do u do that?

I want it this way:



Furniture
Office
Total for East
Furniture
Office
Total for West


with a column per year on the right side of course. I couldnt right it properly. but I hope u understand how I want it.
Message was edited by: nidhi123 Message was edited by: nidhi123
ballardw
Super User
Depending on what you mean per Cynthia's questions, I have had occasion to want both a code and text at the same time. My approach has been, in the steps that create the input data set, to create a new text variable that is the concatenation of the code and the text. Pick the order to concatenate depending on how you want the sort order in the tables.
nidhi123
Calcite | Level 5
Thanks for ur answers cynthia and ballardw.

I think my solution is in ur tip ballardw. I will try this, and get back to u guys.. thanks again.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 665 views
  • 0 likes
  • 3 in conversation