My dataset looks like this
ID X
1001 5
1002 3
. .
. .
1002 4
1003 3
1003 6
1003 4
. .
. .
1003 3
1004 2
. .
. .
. .
Now I need only one ID and X value in each row. For example I need the sum of X values for...
I am getting an awry table.
It is a 10 column 10 row table and this is how my table looks like.
type
1 2 3 4 5 6
7 8 9 10
Color
1 data ...........
2
3 data............
4 .
5 .
6 .
7
8
9
10
I don't...
Thanks again Mdieckman! My problem is this
I got this data
XYZAA 20080721 2 1420 10022 A N N
XYZAA 20080721 2 1421 11001 A N N
XYZAA 20080721 2 1421 9877 A N N
I need to give them titles so I use this:
INPUT code $ 1-5 date 7-14 session 16 hour 18-21...
When the length of strings are different we use $varyingw. What do we use when numeric values have varying length.
Ex.
code price size
aaa 3000 400
bbb 200 5000
ddd 50000 60
Thanks
actually the problem occurs when there are two consecutive E.
Because of this line
if REC = 'E' THEN difference = abs(num - prev_num);
It only calculates the difference between two E lines instead subtracting E's value from the last C.
So I added one more retain line, in short it looks...
OK I see where the problem is
Diff
A 14966
B 14884 82 (right)
A 14964 80 (true)
A 14962 78 (ok)
B 14885 77 (still fine)
B 14887 2 (here is the PRoblem, this should have been 75)
B 14888 1 (should have been 74)
A 14961 73 (it is fine again)
You see the problem starts when...
Yes I have altered it
My table looks like this
Type Price
A 14500
B 13900
B 13950
A 14550
B 14000
B .
B .
A .
A
A
B
A
.
.
So I changed your code into
data temp1;
set temp2;
retain prev_e;
prev_type = lag(type);
prev_price = lag(price);
if prev_type = 'A' then...
Sorry I tried the exact code that you have written and it does what I asked for but when I apply it to my data it gives the results that I just wrote above.
I don't understand the only difference is that you have written "output".
The file that I am using is more than 1GB which is full of...
Thanks Mdieckman. I get this result from your code.
diff
E 100 10
C 110 2
C 112 1
C 111 10
E 101
But I was trying to get
diff
E 100
C 110 10=>110-100
C 112 12=>112-100
C 111 11=>111-100
E 101 10=>abs(101-111)
Thanks again Dunnes. I thought of that and I thought several other methods but I am not at a level that I can apply the things that I can think of. I greatly appreciate it if someone could send me an algorithm that I can apply to my problem.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.