BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
kindbe17
Fluorite | Level 6

Masters, please help me keeping this view i show below

STATISTIC

1987 Salary

Hits in 1986

N

XX

XX

Mean (Std)

XX.X (XX.XX)

XX.X (XX.XX)

Median

XX.X

XX.X

Min, Max

XX, XX

XX, XX

 

when i merge 2 datasets together i see that the priority of Statistics has been mixed like this

Screenshot 2023-04-20 175934.png

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Add a sequence variable to newone and newone1 and then after the merge you have DATA DOUBLE, sort that by the sequence number.

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

We would need to see the code you are using.

 

--
Paige Miller
kindbe17
Fluorite | Level 6

Here you go

 

%macro cplayers(DS=,var1=,var2=);
proc freq data=&DS.;
tables &var1.*&var2.;
run;
%mend cplayers;

%cplayers(DS=players,var1=div,var2=team);
%cplayers(DS=players,var1=league,var2=position);
Run;


%macro baseplay(Datab=,var1=,var2=);
proc means data=&Datab.;
Var &var1. &var2.;
output out=baseplay_1 N=N1 Mean=Mean1 Std=Std1 Median=Median1 Min=Min1 Max=Max1;
run;
%mend baseplay;
%baseplay(Datab=players,var1=salary,var2=nhits);
;
run;


data newdat;
set Baseplay_1;
N=strip(put(N1,20.1));
MeanSTD=strip(put(Mean1,20.1)) || '(' || strip(put(Std1,20.1))|| ')';
Median=strip(put(Median1,20.1));
MinMax=strip(put(Min1,20.1))|| ',' || strip(put(Max1,20.1));
run;

proc transpose data = newdat out=newdat1;
Var N MeanSTD Median MinMax;
run;

 

 

%let n= 1987 Salary;
data newone (rename =(_Name_=Statistic Col1="&n"n));
set newdat1;
run;

%let m= Hits in 1986;
data newone1(rename=(_Name_=Statistic Col1="&m"n));
set newdat1;
run;

proc sort data=newone;
by Statistic;
run;

proc sort data=newone1;
by descending Statistic;
run;

data double;
merge newone newone1;
;
run;

PaigeMiller
Diamond | Level 26

Add a sequence variable to newone and newone1 and then after the merge you have DATA DOUBLE, sort that by the sequence number.

--
Paige Miller
kindbe17
Fluorite | Level 6

Thanks Genius.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 219 views
  • 0 likes
  • 2 in conversation