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

A is:

countpctyeary
327518.620120
352008.420131
344227.820142
361957.620153
390357.520164
430607.620175
3606736.220120
3572945.920131
3419965.320142
3419635.120153
3512315.220164
3664215.320175
254326.620120
252196.020131
239475.420142
252395.320153
270195.220164
291035.120175
2749084.720120
2571684.220131
2358243.620142
2346453.520153
2377803.520164
2474933.620175
73191.920120
99812.420131
104752.420142
109562.320153
120162.320164
139572.520175
857651.520120
1001261.720131
1061721.620142
1073181.620153
1134511.720164
1189281.72017

5

 

 

 

B is :

 

327518.63606736.2254326.62749084.773191.9857651.5
352008.43572945.9252196.02571684.299812.41001261.7
344227.83419965.3239475.42358243.6104752.41061721.6
361957.63419635.1252395.32346453.5109562.31073181.6
390357.53512315.2270195.22377803.5120162.31134511.7
430607.63664215.3291035.12474933.6139572.51189281.7
1 ACCEPTED SOLUTION

Accepted Solutions
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

this is a nice link that explains proc transpose.

Example 3 should answer your needs.

https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/

reshaping data with 2 variables

 

View solution in original post

9 REPLIES 9
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

what are you transposing on?

you have no column names in B.

walterwang
Obsidian | Level 7

That is

count pct count pct count pct

 

 

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

this is a nice link that explains proc transpose.

Example 3 should answer your needs.

https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/

reshaping data with 2 variables

 

novinosrin
Tourmaline | Level 20

See if this helps

 


data have;
input vcount	pct	year	y;
cards;
32751	8.6	2012	0
35200	8.4	2013	1
34422	7.8	2014	2
36195	7.6	2015	3
39035	7.5	2016	4
43060	7.6	2017	5
360673	6.2	2012	0
357294	5.9	2013	1
341996	5.3	2014	2
341963	5.1	2015	3
351231	5.2	2016	4
366421	5.3	2017	5
25432	6.6	2012	0
25219	6.0	2013	1
23947	5.4	2014	2
25239	5.3	2015	3
27019	5.2	2016	4
29103	5.1	2017	5
274908	4.7	2012	0
257168	4.2	2013	1
235824	3.6	2014	2
234645	3.5	2015	3
237780	3.5	2016	4
247493	3.6	2017	5
7319	1.9	2012	0
9981	2.4	2013	1
10475	2.4	2014	2
10956	2.3	2015	3
12016	2.3	2016	4
13957	2.5	2017	5
85765	1.5	2012	0
100126	1.7	2013	1
106172	1.6	2014	2
107318	1.6	2015	3
113451	1.7	2016	4
118928	1.7	2017	5
;
proc transpose data=have out=w;
by  year notsorted;
var vcount pct;
run;

proc sort data=w out=ww(keep=year col1);
by year;
run;

proc transpose data=ww out=want(drop=_name_);
by year;
var col1;
run;

Tom
Super User Tom
Super User

That looks like a report instead of a dataset. 

Easy to do in PROC REPORT, but your source data has no grouping variable.

Looks like a new group starts whenever Y=0.

data have;
  input count pct year y @@;
  group+(y=0);
cards;
32751 8.6 2012 0 35200 8.4 2013 1 34422 7.8 2014 2 36195 7.6 2015 3 39035 7.5 2016 4 43060 7.6 2017 5
360673 6.2 2012 0 357294 5.9 2013 1 341996 5.3 2014 2 341963 5.1 2015 3 351231 5.2 2016 4 366421 5.3 2017 5
25432 6.6 2012 0 25219 6.0 2013 1 23947 5.4 2014 2 25239 5.3 2015 3 27019 5.2 2016 4 29103 5.1 2017 5
;

proc report data=have ;
 column group year,(count pct) ;
 define group / group ;
 define year / across ;
run;

image.png

walterwang
Obsidian | Level 7

I need further process.

 

Tom
Super User Tom
Super User

@walterwang wrote:

I need further process.

 


Then keep it in the form you have where it is usable.

walterwang
Obsidian | Level 7

How to save the ourtput from tabulate as a data set? Any idea, thanks

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 1594 views
  • 0 likes
  • 4 in conversation