l*********s 发帖数: 5409 | 1 1)create a dataset holding the last nonmissing values for each group
2)do a sql join with original data set |
|
l****z 发帖数: 29846 | 2 Eric Holder defends using Justice Department airplane for 27 personal trips
By Joel Gehrke | APRIL 4, 2014 AT 4:18 PM
Attorney General Eric Holder disputed a Government Accountability Office
report on his use of Justice Department airplanes for personal trips, saying
it overstated the number of trips he took and failed to recognize that some
trips were job-related.
"My staff keeps telling me to take it easy, you know, well, this is one that
gets me," Holder told Rep. Frank Wolf, R-Va., during a ... 阅读全帖 |
|
w******i 发帖数: 1476 | 3 SAS Interview Questions from http://www.sconsig.com/
Very Basic
What SAS statements would you code to read an external raw data file to a DATA
step?
How do you read in the variables that you need?
Are you familiar with special input delimiters? How are they used?
If reading a variable length file with fixed input, how would you prevent SAS
from reading the next record if the last variable didn't have a value?
What is the difference between an informat and a format? Name three informats
or format... 阅读全帖 |
|
c****t 发帖数: 19049 | 4 THE GHASTLY ORDEAL OF TIMOTHY CAVENDISH
One bright dusk, four, five, no, my God, six summers ago, I strolled along a
Greenwich
avenue of mature chestnuts and mock oranges in a state of grace. Those
Regency residences
number among London’s costliest properties, but should you ever inherit one
, dear Reader, sell
it, don’t live in it. Houses like these secrete some dark sorcery that
transforms their owners into
fruitcakes. One such victim, an ex-chief of Rhodesian police, had, on the
evening in qu... 阅读全帖 |
|
f*****a 发帖数: 496 | 5 这个用sas做很简单,再大的数据量都能很准很快的算出来。
方法: Last nonmissing value forward
/*读数据,处理原数据*/
data a;
input ID DRUG_DOSAGE $ @@;
cards;
1 0.4
1 NA
1 NA
1 0
1 NA
2 0.6
2 NA
2 0
3 NA
3 0.2
3 NA
3 NA |
|
S******y 发帖数: 1123 | 6 should be --
...
else if level=2 or level= 3 then expertise='Medium';
...
3 is always true sinceany nonzero, nonmissing constant is always true |
|
r********e 发帖数: 1686 | 7
哎呀, 我忘记说清楚了。
又三个variable, 分别是group, date, value
每个group自打同一个date后的value都是missing的,然后这些missing值要取上一个值的1/2次方。最后一个nonmissing 的date都是相同的,然后missing的值的
date也是一样的。
retain的话赋值就要by group 那样了,不知道怎么弄才行。
group date value
a 01/01/09 10
a 01/02/09 missing
b 01/01/09 23
b 01/02/09 missing
c
c
d
d
...... |
|
r********e 发帖数: 1686 | 8 RT
if I have a dataset as below:
id week value1
a 1 12
a 2 22
a 3 33
a 4 .
a 5 .
a 6 .
a 7 .
b 1 78
b 2 .
b 3 .
b 4 .
b 5 .
b 6 .
b 7 .
b 8 .
c 1 88
c 2 67
c 3 76
c 4 .
c 5 .
c 6 .
I need to capture the last missing value1 for each ID as value2 to achieve
the following dataset:
id week value1 value2
a 1 12 33
a 2 22 33
a 3 33 33
a... 阅读全帖 |
|
|
k*******a 发帖数: 772 | 10 写了一个,不过有点繁
data a;
input id $ week value1;
datalines;
a 1 12
a 2 22
a 3 33
a 4 .
a 5 .
a 6 .
a 7 .
b 1 78
b 2 .
b 3 .
b 4 .
b 5 .
b 6 .
b 7 .
b 8 .
c 1 88
c 2 67
c 3 76
c 4 .
c 5 .
c 6 .
;
data b;
set a;
by id;
if value1 ne . then do
value2=value1;
retain value2;
end;
if last.id then output;
keep id value2;
data a;
merge a b;
by id;
proc print data=a;run; |
|
R*********i 发帖数: 7643 | 11 It souds like a typical LOCF question:
proc sort data=a;
by id week;
data locf;
set a;
by id week;
where value1>.;
if last.id;
data out;
merge a locf (keep=id value1 rename=(value1=value2));
by id ;
proc print;
run; |
|
l**********9 发帖数: 148 | 12
Nice~~~
set by id就可以了吧?不需要by week了吧? |
|
G**7 发帖数: 391 | 13 According to Ron Cody, you can use "proc tabulate' to count missing and
nonmissing values for both character and numeric variables. |
|