Hi,
I have below table:
Month | Type | Count | Value1 | Value2 | Value3 | Value4 |
01. April | Auto | 738 | 27.6 | 32.78 | 8.11 | 9.01 |
01. April | Voluntary | 221 | 10.05 | 10.66 | 2.43 | 3.33 |
02. May | Auto | 261 | 8.03 | 6.55 | 2.88 | 2.8 |
02. May | Voluntary | 108 | 4.14 | 4.43 | 1.2 | 1.64 |
03. June | Auto | 173 | 5.99 | 3 | 1.91 | 1.86 |
03. June | Voluntary | 120 | 5.46 | 0 | 0.13 | 0.18 |
I want to convert it to:
01. April | 01. April | 02. May | 02. May | 03. June | 03. June | |
Auto | Voluntary | Auto | Voluntary | Auto | Voluntary | |
Count | 738 | 221 | 261 | 108 | 173 | 120 |
Value1 | 27.6 | 10.05 | 8.03 | 4.14 | 5.99 | 5.46 |
Value2 | 32.78 | 10.66 | 6.55 | 4.43 | 3 | 0 |
Value3 | 8.11 | 2.43 | 2.88 | 1.20 | 1.91 | 0.13 |
Value4 | 9.01 | 3.33 | 2.80 | 1.64 | 1.86 | 0.18 |
Please help.
Please supply example data in usable form (data step with datalines), so we can see exactly (in terms of types and other variable attributes) what we are dealing with.
Is your expected result a dataset or a report? Mind that you can't group variables like that in a dataset.
You could use proc tabulate:
data have;
input Month :&$12. Type :$12. Count Value1 Value2 Value3 Value4;
datalines;
01. April Auto 738 27.6 32.78 8.11 9.01
01. April Voluntary 221 10.05 10.66 2.43 3.33
02. May Auto 261 8.03 6.55 2.88 2.8
02. May Voluntary 108 4.14 4.43 1.2 1.64
03. June Auto 173 5.99 3 1.91 1.86
03. June Voluntary 120 5.46 0 0.13 0.18
;
proc tabulate data=have;
class month type;
var Count Value1 Value2 Value3 Value4;
table (Count*format=6.0 Value1 Value2 Value3 Value4), month=""*type=""*max="";
run;
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.