09-01-2015
CharlesR
Calcite | Level 5
Member since
06-23-2011
- 58 Posts
- 0 Likes Given
- 0 Solutions
- 0 Likes Received
-
Latest posts by CharlesR
Subject Views Posted 3993 04-28-2011 02:52 PM 1631 04-28-2011 01:57 PM 865 04-28-2011 12:08 AM 871 04-27-2011 11:46 PM 1631 04-27-2011 10:47 PM 1069 04-27-2011 01:51 PM 1109 04-27-2011 01:58 AM 1669 04-27-2011 01:53 AM 1097 04-27-2011 12:40 AM 1010 04-27-2011 12:19 AM -
Activity Feed for CharlesR
- Posted Concatenate a variable, can i then reverse the process? on SAS Programming. 04-28-2011 02:52 PM
- Posted Re: tough one: merge 2 datasets, need to reduce 5 variables to one on SAS Programming. 04-28-2011 01:57 PM
- Posted Re: Proc Freq - can't get the right by/tables variables to get the % i want on SAS Procedures. 04-28-2011 12:08 AM
- Posted Proc Freq - can't get the right by/tables variables to get the % i want on SAS Procedures. 04-27-2011 11:46 PM
- Posted Re: tough one: merge 2 datasets, need to reduce 5 variables to one on SAS Programming. 04-27-2011 10:47 PM
- Posted Re: Proc SQL, Tough one: Merge 2 datasets, many to many Match Merge on SAS Procedures. 04-27-2011 01:51 PM
- Posted Proc SQL, Tough one: Merge 2 datasets, many to many Match Merge on SAS Procedures. 04-27-2011 01:58 AM
- Posted tough one: merge 2 datasets, need to reduce 5 variables to one on SAS Programming. 04-27-2011 01:53 AM
- Posted Tough one: Merge 2 datasets, many to many Match Merge, proc sql? on SAS Procedures. 04-27-2011 12:40 AM
- Posted Merge 2 datasets, many to many Match Merge on SAS Programming. 04-27-2011 12:19 AM
- Posted Re: Merging 2 datasets, column location a real pain on SAS Programming. 04-21-2011 12:17 PM
- Posted Re: Merging 2 datasets, column location a real pain on SAS Programming. 04-21-2011 01:30 AM
- Posted Merging 2 datasets, column location a real pain on SAS Programming. 04-21-2011 01:29 AM
- Posted Re: return first digit of a numeric variable on SAS Programming. 04-18-2011 03:31 PM
- Posted Re: return first digit of a numeric variable on SAS Programming. 04-18-2011 01:37 PM
- Posted return first digit of a numeric variable on SAS Programming. 04-17-2011 11:27 PM
- Posted Re: transpose data from one variable on SAS Programming. 04-15-2011 11:59 PM
- Posted Re: transpose data from one variable on SAS Programming. 04-15-2011 11:57 PM
- Posted Re: transpose data from one variable on SAS Programming. 04-15-2011 10:17 PM
- Posted transpose data from one variable on SAS Programming. 04-15-2011 05:14 PM
04-28-2011
02:52 PM
I'm concatenating a variable to make the process of merging 2 datasets together go a lot faster, but once this is done, i'd really like to get things back to the original variables. Is this possible?
... View more
04-28-2011
01:57 PM
Indeces aren't quite as important as the final set post-proc freq has only 63,000 observations.
And yes, there are spaces which are left over, but the variables are fairly small, so this isn't a huge prob, but you're right, i should concatenate diff.
What's more important is the ability to use the concatenated variable in a merge with another data set. It's significantly faster to run a merge with a a single variable as the merge by variable, rather than using the group of variables.
... View more
04-28-2011
12:08 AM
Never mind, it's by PlayRes_forPerc (PR). sheesh. Been working too many late nights.
... View more
04-27-2011
11:46 PM
Hi,
This should be crazy easy, buti just can't get the right combo of variables in the by and tables portion to give me the percentages i want.
i'm running proc freq like this:
[pre]
proc freq data = Def_Hits noprint;
by zone BallInPlayType BattedBallVelocity DblPlayPosn BatSide PlayRes_forPerc;
tables Respfielder/ out = UZR;
run;
[/pre]
and it's outputting this:
[pre]
zone BPT BBV DP BSi PR Rf COUNT PERCENT
78D 1 2 Y L Out 1 2 0.913242009
78D 1 2 Y R Out 1 1 0.510204082
78D 1 3 N R Hit 1 3 0.563909774
78D 1 3 N R Out 1 1 0.178571429
[/pre]
What i want is for it to look like this:
[pre]
zone BPT BBV DP BSi PR Rf COUNT PERCENT
78D 1 2 Y L Out 1 2 100
78D 1 2 Y R Out 1 1 100
78D 1 3 N R Hit 1 3 75
78D 1 3 N R Out 1 1 25
[/pre]
in other words, for each combination of variables around the PR variable (Out/Hit), I want the percentage to calculate based on the count.
I'm just brain dead at this point and have tried several different permutations of by/tables and just can't get what i need. Anyone out there able to help this brain dead fellow out?
Thanks!
Message was edited by: CharlesR
... View more
04-27-2011
10:47 PM
That's exactly what i did with concatenation. You can also create the variable like this:
[pre] Scenarios = zone||BallInPlayType||BattedBallVelocity||DblPlayPosn||BatSide||PlayRes_forPerc;[/pre]
Thanks a bunch for the help!
Message was edited by: CharlesR
... View more
04-27-2011
01:51 PM
That's exactly what i mean. Though i ended up concatenating the variables to form one variable.
... View more
04-27-2011
01:58 AM
Ok, so the previous thread i started, i don't think can be accomplished as stated. But i think this will work:
I'm trying to do a many-to-many match merge, but i have a problem: rather than having 1 variable = 1 variable, i have 5 variables to merge "by". I don't think i can do this in SAS, but it would also work to have the 5 variables compound to one variable showing each of the permutations of the 5, then doing the merge by the new single variable. I could then do the merge using Proc SQL with: one variable showing the permutations = one variable showing the permutations.
Can anyone show me how to do this?
Thanks!
... View more
04-27-2011
01:53 AM
Hello,
I'm trying to do a many-to-many match merge, but i have a problem: rather than having 1 "by" variable, i have 5 "by" variables. I don't think i can do this in SAS, but it would also work to have the 5 variables compound to one variable showing each of the permutations of the 5, then doing the merge by the new single variable.
Can anyone show me how to do this?
Thanks!
Message was edited by: CharlesR
... View more
04-27-2011
12:40 AM
Hello,
I know I can do a one-to-many match merge, but can I do a many to many match merge?
Essentially, i have 3 variables to match by, but here's where things get tricky: some of the observations from one set will not have corresponding matches in the second, while other observations will have multiple matches to the second set. The following three sets represent what i'm referring to, with the first two the sets to merge and the last what i want the final set to look like. I think i can do this with proc sql, but am not sure how.
With this first set, the first 2 variables don't appear in the second set. Then come the 3 variables to match by.
The next set starts with the 3 variables to match by, then the variables to add to the final set.
The final set shows how the observations in the first set, where PRP='Out' have no values from fbp and Percent from the second. The other observations, where PRP='Hit' then duplicate themselves to account for the 3 situations which occur when PRP is a 'Hit'.
I know this is a touch confusing, so please feel free to ask questions.
[pre]
data set1;
input Hit Z zn BSi$ PRP$;
datalines;
5 100 23 L Out
5 100 23 L Hit
5 100 23 L Out
5 100 23 L Hit
5 100 23 L Out
14 87.5 23 R Out
14 87.5 23 R Hit
14 87.5 23 R Hit
14 87.5 23 R Out
run;
data set2;
input zn BPT BBV DP$ BSi$ PRP$ fbp Percent;
datalines;
23 L Hit 3 .8
23 L Hit 4 .1
23 L Hit 9 .1
23 R Hit 3 .6
23 R Hit 4 .3
23 R Hit 9 .1
run;
data set3;
input Hit Z zn BSi$ PRP$ fbp Percent;
datalines;
5 100 23 L Out . .
5 100 23 L Hit 3 .8
5 100 23 L Hit 4 .1
5 100 23 L Hit 9 .1
5 100 23 L Out . .
5 100 23 L Hit 3 .8
5 100 23 L Hit 4 .1
5 100 23 L Hit 9 .1
5 100 23 L Out . .
14 87.5 23 R Out . .
14 87.5 23 R Hit 3 .6
14 87.5 23 R Hit 4 .3
14 87.5 23 R Hit 9 .1
14 87.5 23 R Hit 3 .6
14 87.5 23 R Hit 4 .3
14 87.5 23 R Hit 9 .1
14 87.5 23 R Out . .
run;
[/pre]
Thanks,
C
... View more
04-27-2011
12:19 AM
Hello,
I know I can do a one-to-many match merge, but can I do a many to many match merge?
Essentially, i have 3 variables to match by, but here's where things get tricky: some of the observations from one set will not have corresponding matches in the second, while other observations will have multiple matches to the second set. The following three sets represent what i'm referring to, with the first two the sets to merge and the last what i want the final set to look like. I think i can do this with proc sql, but am not sure how.
With this first set, the first 2 variables don't appear in the second set. Then come the 3 variables to match by.
The next set starts with the 3 variables to match by, then the variables to add to the final set.
The final set shows how the observations in the first set, where PRP='Out' have no values from fbp and Percent from the second. The other observations, where PRP='Hit' then duplicate themselves to account for the 3 situations which occur when PRP is a 'Hit'.
I know this is a touch confusing, so please feel free to ask questions.
[pre]
data set1;
input Hit Z zn BSi$ PRP$;
datalines;
5 100 23 L Out
5 100 23 L Hit
5 100 23 L Out
5 100 23 L Hit
5 100 23 L Out
14 87.5 23 R Out
14 87.5 23 R Hit
14 87.5 23 R Hit
14 87.5 23 R Out
run;
data set2;
input zn BPT BBV DP$ BSi$ PRP$ fbp Percent;
datalines;
23 L Hit 3 .8
23 L Hit 4 .1
23 L Hit 9 .1
23 R Hit 3 .6
23 R Hit 4 .3
23 R Hit 9 .1
run;
data set3;
5 100 23 L Out . .
5 100 23 L Hit 3 .8
5 100 23 L Hit 4 .1
5 100 23 L Hit 9 .1
5 100 23 L Out . .
5 100 23 L Hit 3 .8
5 100 23 L Hit 4 .1
5 100 23 L Hit 9 .1
5 100 23 L Out . .
14 87.5 23 R Out . .
14 87.5 23 R Hit 3 .6
14 87.5 23 R Hit 4 .3
14 87.5 23 R Hit 9 .1
14 87.5 23 R Hit 3 .6
14 87.5 23 R Hit 4 .3
14 87.5 23 R Hit 9 .1
14 87.5 23 R Out . .
run;
[/pre]
Thanks,
C
Message was edited by: CharlesR
Message was edited by: CharlesR
... View more
04-21-2011
12:17 PM
h'm. i have a LOT of variables. As in around 60. So that may or may not work depending. Is there another way that you know of to put a certain set of variables at the end of your dataset?
... View more
04-21-2011
01:30 AM
Never mind, just switch the order of the datasets in the merge statement
... View more
04-21-2011
01:29 AM
Hello,
I'm merging 2 datasets. The final dataset has about 60 columns. To continue with my programming, some of the variables i am merging by, and the variables which get added from one of the datasets, appear amongst the first few columns, but i really want them at the end. I know i can go in and manually move them down the list, but this is a real pain in the neck to do over and over as i work in new code and re-run the code.
Is there a simpler way to move a column in a data set?
... View more
04-18-2011
03:31 PM
Hey KSharp,
Is there a way to use this to create a numeric variable instead of a character one? or do i just need to convert it back to a numeric after i'm done?
Thanks,
cr
... View more
04-18-2011
01:37 PM
Thanks to everyone for the responses! Really appreciate all the help!!
... View more