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.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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.

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
  • 298 views
  • 0 likes
  • 2 in conversation