DATA Step, Macro, Functions and more

Unmerge Tabulate Variable

Reply
Contributor
Posts: 42

Unmerge Tabulate Variable

Hi,

 

How do I change my tabulate from looking like this.....

 

 CountPercent 
PFFYMonth1200.946
ADec-17  
 Jan-185418
 Nov-1727
 Oct-17618
BDec-1720.327
 Jan-18228
 Nov-172761
 Oct-1727
CDec-1728
 Jan-181523.491
 Nov-1717
 Oct-17599
DDec-17418
 Jan-1828
 Nov-1710.046
 Oct-1748
EDec-1768
 Jan-18184
 Nov-17384
 Oct-17480.033

 

To this.......

 

 CountPercent 
PFFYMonth1200.946
ADec-17  
AJan-185418
ANov-1727
AOct-17618
BDec-1720.327
BJan-18228
BNov-172761
BOct-1727
CDec-1728
CJan-181523.491
CNov-1717
COct-17599
DDec-17418
DJan-1828
DNov-1710.046
DOct-1748
EDec-1768
EJan-18184
ENov-17384
EOct-17480.033
Super User
Super User
Posts: 9,386

Re: Unmerge Tabulate Variable

Posted in reply to Brandon16

Do it in a datastep.

 

Not a verbose answer, its because you have provided no information refer to the help by the post a question button.  Post sample test data in the form of a datastep.  Post your code using the code window (its the {i}). post logs if they have any information, and show what the output should look like.

 

You have some 3 or 4 same posts on here at the moment on the same subject, why not close them off and tell us what the real problem is your trying to face rather than start with "must use XYZ".

Contributor
Posts: 42

Re: Unmerge Tabulate Variable

The problem is I am encountering these issues as the code develops so hard to foresee at the time what Is needed. Each post is at the time of a problem and as I am learning, I don't know what issue I will face next, hence the multiple threads.
Super User
Super User
Posts: 9,386

Re: Unmerge Tabulate Variable

Posted in reply to Brandon16

But you have some base data which you can supply as test data (in the form of a datastep: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...), and you must have some plan or spec of where you want to get to.  None of what you post in this question shows what any of it means or where it comes from.

Contributor
Posts: 42

Re: Unmerge Tabulate Variable

This is the Tabulate code which produces the first table output

 

proc tabulate data = test.testing;
class pf fymonth;
var count percent;
keylabel SUM = ' ';
tables (pf="PF" * fymonth = "FYMonth"),
(count="Count")
(percent="percent"*f=8.3) /row=float;
run;

Super User
Posts: 9,867

Re: Unmerge Tabulate Variable

Posted in reply to Brandon16

In order for us to recreate your situation, we need valid example data.

Please post a sample of test.testing IN A DATA STEP.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 42

Re: Unmerge Tabulate Variable

Posted in reply to KurtBremser

This is the datastep

 

proc sql;
create table test.testing as select
distinct cmonth,
contactnumber,
pf,
fymonth,
from newtest_all
group by cmonth;

Super User
Posts: 9,867

Re: Unmerge Tabulate Variable

Posted in reply to Brandon16

Brandon16 wrote:

This is the datastep

 

proc sql;
create table test.testing as select
distinct cmonth,
contactnumber,
pf,
fymonth,
from newtest_all
group by cmonth;


This is VERY OBVIOUSLY NOT A DATA STEP! (its a proc sql that references another table we have zero information about, so it's of no value to us)

 

Post your example data in a data step with datalines, so we can recreate your data as is with a copy/paste and submit.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 42

Re: Unmerge Tabulate Variable

Posted in reply to KurtBremser

We have a datAset loaded into SAS and I have written a PROC SQL to bring back the variables I need. I'm not sure what else I can provide you as I don't create/load the dataset stored within SAS. 

Super User
Posts: 9,867

Re: Unmerge Tabulate Variable

Posted in reply to Brandon16

@RW9 has already provided you with the means to create a datastep from an existing dataset. Use it.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 9 replies
  • 84 views
  • 0 likes
  • 3 in conversation