I have a question and want to ask question by using example. My data-set is:
Group Value
1 10
1 8
1 12
2 13
2 11
2 7
I want to add two columns to this data-set. First column should consist of maximum value of second column by group. Second column should consist of minimum value of second column by group. So, the result should be look:
Group Value Max Min
1 10 12 8
1 8 12 8
1 12 12 8
2 13 13 7
2 11 13 7
2 7 13 7
12 - because there are 3 numbers (10,8,12) in group number 1 and 12 is maximum among these values.
13 - because there are 3 numbers (13,11,7) in group number 2 and 13 is maximum among these values.
8 - because there are 3 numbers (10,8,12) in group number 1 and 8 is minimum among these values.
7 - because there are 3 numbers (13,11,7) in group number 2 and 7 is minimum among these values.
I hope, i can explain it..
Many thanks in advance.
Try:
proc sql;
select *,max(value) as max,min(value) as min from have group by group;
quit;
Related
I am having trouble with a .txt data set that is separated by spaces. It is in list input format and I want to separate it into three columns.
I've tried using row pointers, column pointers, and other methods within the input statement. I've been searching online and I think an array would work in this situation but I'm not sure how to do that (I'm new to SAS).
1 1 2 2 1 1 3 1 2 4 0 3 5 1 3 6 1 2 7 0 3 8 1 3 9 0 1 10 0 2 11 1 1
I want the data to be in columns:
ID Group Time.
1 . 1 . 2
2 . 1 . 1
3 . 1 . 2
The id numbers go up to 90
Use the held line input modifier ##:
filename mydata "whatever.txt";
data want;
infile mydata;
input id group time ##;
run;
We got 28 numbers and we write them in lines. Every line consists of 6 numbers. If we pick 5 numbers randomly from 28 numbers we wanna cover all posibble combinations of 3 numbers in minimum lines posbile. Example:
if we pick 4 5 12 16 22 we wanna have 4 5 12, 4 5 16, 4 5 22 ect. (10 combinations)
in one or more lines but gota have all combinations covered in minimum posible lines.
This question already has answers here:
My regex is matching too much. How do I make it stop? [duplicate]
(5 answers)
Closed 3 years ago.
I have the following output:
WordA
1
2
3
4
WordB
5
6
7
8
WordC
9
10
11
12
WordA
13
14
15
16
WordB
I need to grab the numbers between the two words: WordA and WordB
I tried (?<=WordA ).*(?= WordB) but the problem is, it grabs ALL the numbers here, including the ones between WordC and WordA that I don't want. I only want to grab the numbers between the 2 pairs which are 1 2 3 4 and 13 14 15 16
Any ideas?
First use this regex:
WordA(\s+\d+)+\s+WordB
this will cut you WITH WordA and WordB.
Then cut the digits with this regex:
\d+
First you will get:
WordA
1
2
3
4
WordB
WordA
13
14
15
16
WordB
Second you will get:
1
2
3
4
13
14
15
16
try this: (?<=WordA).*?(?=WordB).
This question already has an answer here:
regex number range 1-17
(1 answer)
Closed 7 years ago.
Need an regex patter to identify an number input with space delimiter, and the number range should be from 1 to 11.
e.g. It should detect following
1 2 3
1 11 4 5 6
1 4 3 9
11 4 5
e.g It should fail in detecting
12 2 3
1 34 5555
23 3445 566 676544
dds 434 fv 434
dssd s ds sd
I came up with
^([0]?\d|1[0-1])(([, ]([0]?\d|1[0-1]))*)$
But this also detect when I provide
1 0 6 7
This is not an duplicate question, and I have explained it well enough. Please read question properly and if still someone thinks it's an duplicate question then tell me why it's a duplicate one instead of just marking an duplicate.
(?:([1-9][01]?)\s+)+ should do it.
Explanation:
(?: non capturing group
([1-9][01] two digits, first between 1 and 9, second optional
)\s+) spaces
)+ repeat the whole
given a binary search tree print all possible inputs that will form the same binary search tree.
one simple example will be
2
1 3
we need to print
2 1 3
2 3 1
10
5 13
3 6 11 15
10 5 13 3 6 11 15
10 13 5 3 6 11 15
...
i tried solving this by reading the tree breadth wise and shuffling it. But, there could be possible input like
10 5 3 6 13 11 15
Do i need to use DFS here ?? am writing it in C++