a********e 发帖数: 3771 | 1 Wow! It's an interesting problem. My code is like this.
proc sort data = one; by id StateDate; run;
data two;
set one;
by id;
if first.id then do;
date1 = StartDate; date2 = EndDate; end;
else do;
if StartDate => date1 then do;
if StartDate =< date2 + 30 AND EndDate > date2 then date2 =
EndDate;
else do;
date1 = StartDate; date2 = EndDate;
end;
end;
end;
retain date1 date2;
id_date1 = id || date1;... 阅读全帖 |
|
d*********g 发帖数: 349 | 2 有两个table已经存在sas系统里了,第一个table 6百多万行,有个date1 column, 格
式都是像 01Jan2012:00:00:00
第二个table 7百多万行, 有个date2 column,格式都是像 01Jan2013:00:00:00:000
第一步把两个table join 起来,date1 和 date2 这两个columns 都需要在里面。这一
步已经做完了。下一步是比较每一行里面的date1 VS date2, 如果date1 在date2 之前
,在comment column里面写 before; 如果date1 在date2 之后,在comment column里
面写after.
请问大家,如何比较快速的把所有date1 date2转变成可以比较大小的日期格式,什么
格式?
谢谢!!! |
|
j******o 发帖数: 127 | 3 Maybe can be simplified like below, but still looking for pure PROC SQL
solution.
-----------------------------
proc sort data=have presorted; by id startdate enddate; run;
data obtain;
set have;
by id startdate;
lag_enddate=lag(enddate);
retain date1;
if first.id then date1=startdate;
else if startdate - lag_enddate > 30 then date1=startdate;
run;
data obtain2;
set obtain;
by id date1 startdate;
if last.date1;
startdate=date1;
keep id startdate enddate;
run;
---... 阅读全帖 |
|
t**********r 发帖数: 182 | 4 Want to merge two data sets using proc sql:
Data1:
var1 var2 date1
Data2:
var1 var2 date2 rating
(Note: var1 and var2 are the same variables in these two data sets)
Question:
Select rating in data2 to data1; meeting the following criteria:
1. date1 - date2 >0
2. date1 - date2 has the minimum value.
I wrote the following code; but it won't work:
proc sql;
create table data3 as
select data1.*, data2.rating, date1-date1 as diff
from data1, data2
where data1.var1=data2.var1 and data1.var2=data2.var2 |
|
t**********r 发帖数: 182 | 5 Want to merge two data sets using proc sql:
Data1:
var1 var2 date1
Data2:
var1 var2 date2 rating
(Note: var1 and var2 are the same variables in these two data sets)
Question:
Select rating in data2 to data1; meeting the following criteria:
1. date1 - date2 >0
2. date1 - date2 has the minimum value.
I wrote the following code; but it won't work:
proc sql;
create table data3 as
select data1.*, data2.rating, date1-date1 as diff
from data1, data2
where data1.var1=data2.var1 a |
|
F**********t 发帖数: 47 | 6 data a;set a;
date1 = MDY(1, 1, 2005);
format date1 YYMMDDN8.; (即使,把这句注释掉以后也不行)
date1 = MDY(1, 1, 2008);
format date1 YYMMDDN8.; (即使,把这句注释掉以后也不行)
IF DATE < date1 THEN DELETE;
IF DATE >= date2 THEN DELETE;
run;
a 表格有2001到2010年之间每个月最后一天的数据。以上代码是要删除2005年以前和
2008年以后的所有数据。可是,得到结果是表格里面没有任何数据了。
log file 里面有说 variable DATE is uninitialized.
但是,我确定变量名是 date, 而且表格a 在当前工作目录下。本来想把表格用附件贴
上来,可是论坛不让。 |
|
k*******a 发帖数: 772 | 7 my code, date1 is start time date2 is stop time(different from your
date2)
data A;
input date $ y;
datalines;
2/1 0
2/2 1
2/3 1
2/4 0
2/5 0
2/6 1
2/7 0
2/8 1
2/9 1
2/10 1
;
run;
data b;
set a;
lagy=lag(y);
if y^=lagy then group+1;
run;
data b(keep=date1 date2 count);
retain date1 date2;
set b;
by group;
if y=1;
if first.group then do;
count=0;
date1=date;
end;
count+1;
if last.group then do;
date2=date;
output;
end;
run;
proc pr... 阅读全帖 |
|
f*******i 发帖数: 8492 | 8 我现在已有一个sas格式现成的data sheet
其中date1的格式是这样的 21MAY2001:00:00:00
但这组数据是character, 而不是date value
所以我需要把这组数据转换成sas的date value,并且减去 "01JAN2001"得到差值
我的code如下:
data homework10;
set class.homework10;
date2=input(date1,date9.);
format date2 date9.;
range=date2-'01JAN2001'dt;
run;
proc print data=homework10;
var date1 date2 range;
run;
现在我的问题,经过打印,我得到的date2确实只是date1里面的日期部分
1. 我所有的date2数值理论上都是大于01JAN2001这个值的,但是得出的range都是负值
,这事怎
么回事? 比如“-1277926548”。
2. 如何把range这个数据以“天数”的形式表示?
谢谢 |
|
f*******i 发帖数: 8492 | 9 是这样的,我已经有一个datasheet,homework10.sas7bdat
然后,其中的date1格式就是“21MAY2001:00:00:00”, 但这个不是numeric value,
而是character
所以我根据楼上说的,先把date1读写为numeric value的date2,再从中提取date部分
data homework10;
set class.homework10;
date2=input(date1,date16.);
format date2 date16.;
date3=datepart(date2);
format date3 date9.;
range=date3-'01JAN2001'dt;
run;
proc print data=homework10;
var date1 date2 date3 range;
run;
如果时间格式是“21MAY2001:00:00:00”, 那么datetime后面跟着的数字是应该取15,
16,17,还是18?
我现在无论取那个数,得到的date2,都是这种格式“21MAY01:00:00:00”,并... 阅读全帖 |
|
a****r 发帖数: 4965 | 10 What is the expiration date of your current EAD? Date1
What is the receipt date of your 485 EAD extension application? Date2
* If Date2 > Date1, you have to wait for your new EAD approval or ask the
company to file H1B for you (if possible).
* If Date2 <= Date1, you have 180 days auto-extension of your current EAD,
then you can work for the new company before the new EAD approval up to 180
days.
(Search "auto EAD extension" on USCIS.gov) |
|
l********u 发帖数: 195 | 11 OrderNo lineNo Status LineType Date1 Date2
1 0001 99 T 07092002(date1)
1 0002 99 S 07012002(date2)
1 0003 50 S
2 0001 99 S 07012002(date2)
2 0002 99 S 07012002(date2)
3 0001 50 T 07092002(date1)
3 0002 99 S 0 |
|
w*******t 发帖数: 928 | 12 data one;
infile cards;
input date $1-12;
format date1 mmddyy10.;
date1=input(compress(date,' .'), date11.);
cards;
09-Aug.-2009
11-Apr.-2009
;
run;
proc sort data=one; by date1; run; |
|
S********a 发帖数: 359 | 13 问个SAS 日期时间转换的问题
一个日期变量 DATE,其value是01-Jan-2010这种形式,并且是字符型。一个时间变量TIME,其value是23:00,即小时:分钟,也是字符型的。我的问题是,我想把它们变成SAS数值型,有什么function可以用吗?
DATA TEST ;
SET A;
DATE=SUBSTR(DATETIME, 1, 11);
TIME=SUBSTR(DATETIME, 13, 5);
DAY = INPUT(SCAN(DATE, 1, "-"),2.);
MONTH = INPUT(SCAN(DATE, 2, "-"),$3.);
YEAR = INPUT(SCAN(DATE, 3, "-"),4.);
IF MONTH="Jan" then month1=1;
else if month="Feb" then month1=2;
else if month="Mar" then month1=3;
else if month="Apr" then month1=4;
else if month="May" then month1=5;
else i... 阅读全帖 |
|
m********5 发帖数: 619 | 14 你这个条件1和条件2我看着怎么重叠啊....
proc sql; create table data3 as select a.*, b.* from data1 as a, data2 as b
where a.var1=b.var1 and a.var2=b.var2 and a.date1-b.date2>=minvalue and a.
date1-b.date2>0;
quit; |
|
t**********r 发帖数: 182 | 15 Many thanks for your hint!! I made it. Here is the code.
579 proc sql;
580 create table data3 as
581 select data1.*, data2.rating, day1-day2 as diff
582 from data1, data2
583 where data1.var1=data2.var1 and data1.var2=data2.var2
584 and date1-date2>0
585 group by data1.var1, data1.var2, data1.date1
586 having diff=min(diff);
NOTE: The query requires remerging summary statistics back with the original
data.
NOTE: Table WORK.data3 created, with 48144 rows and 9 |
|
O******i 发帖数: 269 | 16 最近面了一家IT大公司被拒,一共经历了N轮技术面试。自己感觉还不算太坏,但也有
三轮发挥不太完美,所以心里很没底。
结果还是被拒了。
下面是这三轮的详细经历,请大家探讨一下大公司招人的标准。
第i轮是找二叉树从根开始的所有路径,使得该路径上所有节点的值之和等于一个给定
的数。我犯了一个战略错误,因为我在准备过程中看过CarrerCup的更通用的解法,不
要求从根开始,也不要求到叶子结束,于是我直接用了那个思路,在白板上写下了类似
下面的代码
void FindPath(Node* root, int sum, int path[], int level)
{
if (root == NULL)
return;
int s = 0;
for (int i = 0; i < level; i++)
s += path[i];
int value = root->data;
if (s + value == sum)
PrintPath(path, level, value);
path[leve... 阅读全帖 |
|
O******i 发帖数: 269 | 17 我要是当时看过题目二就好了,哎...
题目一,我的面经,出处
http://www.mitbbs.com/article_t/JobHunting/32010769.html
有一个类,里头有两个Date对象
class T
{
Date date1;
Date date2;
}
其中Date是形如12/05/2011这样的日期,date1 <= date2,这样T就表示一个时间段。
假如有两个T类型的变量a,b,如果a和b代表的时间段之间没有gap, 也就是a和b
overlap, 则集合{a, b}是连续的。然后他解释扩展到多个时间段,什么情况下他们的
集合是连续的。
他的问题是,给你一个T类型变量的list,如何判断这个list是连续的还是不连续的。
我很快发现,每个Date在时间轴上是一个点,每个时间段T的变量是时间轴上的一条线
段,这题完全可以等同于
class Seg
{
int start;
int end;
}
其中 start <= end, 这样Seg就表示数轴上的线段。两条线段如果overlap,包括
overlap于一个点,则连续... 阅读全帖 |
|
G***l 发帖数: 355 | 18 这个是很好,但是好像也偶缺陷。比如我以前用Java写,用户输入是各种文本,然后在
后台程序里,我在Java里面把这些文本parse成AST并且interpret,最后得到他们的结
果,比如:
用户写的dsl是MonthDiff(Date1, Date2) + 1 > SomeValue
我读入这个文本到monthControl, 并且在inputData里放入Date1, Date2, SomeValue的
值(从数据库或者什么地方读过来的)。然后写,
//evaluate里做parsing和interpret
result = evaluate(monthControl, inputData)
if(result)
{
//do business logic
}
这样用户就可以写dsl直接控制我程序里的logic。假如改用haskell用embedded的话,
我的haskell程序没法直接调用那个dsl,除非把那个dsl写到我的source code,然后动
态编译运行,但是我不想要那样。或者可以有什么类似swig之类的东西让我动态调用
haskell code,但是我没法... 阅读全帖 |
|
G***l 发帖数: 355 | 19 这个是很好,但是好像也偶缺陷。比如我以前用Java写,用户输入是各种文本,然后在
后台程序里,我在Java里面把这些文本parse成AST并且interpret,最后得到他们的结
果,比如:
用户写的dsl是MonthDiff(Date1, Date2) + 1 > SomeValue
我读入这个文本到monthControl, 并且在inputData里放入Date1, Date2, SomeValue的
值(从数据库或者什么地方读过来的)。然后写,
//evaluate里做parsing和interpret
result = evaluate(monthControl, inputData)
if(result)
{
//do business logic
}
这样用户就可以写dsl直接控制我程序里的logic。假如改用haskell用embedded的话,
我的haskell程序没法直接调用那个dsl,除非把那个dsl写到我的source code,然后动
态编译运行,但是我不想要那样。或者可以有什么类似swig之类的东西让我动态调用
haskell code,但是我没法... 阅读全帖 |
|
t**********r 发帖数: 182 | 20 Has figured it out. Thanks.
===============
579 proc sql;
580 create table data3 as
581 select data1.*, data2.rating, day1-day2 as diff
582 from data1, data2
583 where data1.var1=data2.var1 and data1.var2=data2.var2
584 and date1-date2>0
585 group by data1.var1, data1.var2, data1.date1
586 having diff=min(diff);
NOTE: The query requires remerging summary statistics back with the original
data.
NOTE: Table WORK.data3 created, with 48144 rows and 9 columns.
587 quit;
NOTE: PROCEDURE SQL used (Tota |
|
y******0 发帖数: 401 | 21 proc sql;
create table data3 as
select data1.var1,data1.var2, data2.rating, min(date1-date2) as diff
from data1, data2
where data1.var1=data2.var1
and data1.var2=data2.var2
and date1>date2
group by 1,2,3;
quit; |
|
b******e 发帖数: 539 | 22 suppose date1 = '19600210', use:
date2 = input(date1, yymmdd8.);
to convert '19600210' to a SAS date.
you can format date2 to any date format you want. for example, you can use
date9:
format date2 date9.;
then date2 will be shown as 10feb1960 |
|
S********a 发帖数: 359 | 23 有100个数据,有个变量名叫:date, 数据是06/17/2008这种形式的
我想把数据分成三个dataset,07/20/2008前,07/20/2008~09/17/2008, 09/17/2008
以后
data b c d;
set a;
format date DATE9.;
date1 = '20JULY2008'd;
date2 = '17SEPT2008'd;
if date < date1 then output b;
if data > date2 then output d;
else output c;
run;
出了error msg : Invalid date/time/datetime constant '20JULY2008'd.
Invalid date/time/datetime constant '17SEPT2008'd.
麻烦帮我看看,我自己觉得没错啊,但是就是不行。
包子答谢! |
|
d******9 发帖数: 404 | 24 "其中date1的格式是这样的 21MAY2001:00:00:00"
包括时间部分,应该用 datetime16.读入,然后把时间部分去除。
dateonly=datepart(date1); |
|
q******d 发帖数: 158 | 25 use datepart(date1), then you can get the date1=21May2001 |
|
s***r 发帖数: 1121 | 26 How can I merge 3 datasets using PROC SQL?
Dataset 1:
Plant date1 Variable1
Unique YYYYMMDD
ID
001 20060914 .....
001 20080801 .....
001 20080822
001 20100101
002 20011119
002 20020101
002 20030808
003 20091212
005 20000816
005 20001225
005 20010205
005 20030203
005 20030501 ....
...
...
....
Dataset 2:
Plant date2 Variable2
Unique YYYYMMDD
ID
001 20050314 ... 阅读全帖 |
|
l*u 发帖数: 114 | 27 乱写一个, 不知道对不对
proc sql;
select DISTINCT PlantUniqueID from dataset1 dataset2 dataset3
where dataset1.PlantUniqueID = dataset2.PlantUniqueID = dataset3.
PlantUniqueID
and dataset1.date1 = dataset2.date2 - 5
or dataset1.date1 = dataset2.date3 + 10
quit; |
|
h******e 发帖数: 1791 | 28 time to event是如何计算的?是date2 - date1 + 1还是date2 - date1?谢谢。 |
|
s******8 发帖数: 102 | 29 我也试一下:
你的问题是数据太大,而又必须排序.所以在排序方法上着手. 若你知道日期跨度,第一
步安天拆分数据,然后对每天排序并检查,最后把结果合并起来.
假如最早date as macro variable Day1, last date as macro variable day2;
%let date1=mdy(1,1,1990);
%let date2=mdy(12,31,2012);
%macro trybest(day1=&date1,day2=&date2);
data %do i=&day1 %to &day2;dt_&i %end;;
set yourdate;
select(date);
%do i=&day1 %to &day2;
when(i) output dt_&i;
%end;
otherwise put "ERROR: other date found " date;
end;
drop date;
run;
%do i=&day1 %to &day2;
%let dsid=%sysfunc(open(dt_&I,i));
%let nobs=%sysf... 阅读全帖 |
|
t**********r 发帖数: 182 | 30 Thank you.
你这个条件1和条件2我看着怎么重叠啊....
No. There are many obs that meet date1 - date2 >0; but I only want the one
with the min value. |
|
c*******g 发帖数: 1996 | 31 要pay的钱很少,忘记了。已经用chase bill pay了,1天发出,还有救吗?谢谢 |
|
b*****e 发帖数: 53215 | 32 可以打个电话跟他们说一声,应该可以不算late |
|
a*****t 发帖数: 221 | 33 打cs,只要在过due date 60 天付款, 不良记录不report;late fee waive掉。。。 |
|
p******c 发帖数: 36 | 34 据说37周以后就不算早产了 问了OB 貌似38周生就停靠谱的 娃也没大问题 还容易顺产
?!
due date1月初了 很想生在圣诞节左右啊
请教有经验的jms怎样有助于催产早生?
我现在基本每天游泳或散步2个小时左右
不知有没帮助
谢谢~ |
|
发帖数: 1 | 35 自己胡写的,不知道对于自己的这个特例这个写法行不行,各种名词的表达也简直吃不
准。不是给RFE,是个fresh的submit。谢谢好人们!
June 19th, 2016
USCIS
Attn: AOS
2501 S. State Hwy, 121 Business
Suite 400
Lewisville, TX 75067
Dear Sir/Madam,
I am in the category of EB-1A, extraordinary ability, and do not need an U.S
. employer to act as a sponsor/petitioner for my Green Card application.
I had been working in AAAA for the past years, and my term was just ended on
Date1 due to the fact that my H1B visa has reached the six year limit. I am
now in Change of... 阅读全帖 |
|
b******e 发帖数: 3348 | 36 你是TSC吗?非常理解你的心情,还是及时跟公司沟通吧,推迟start date1-2个礼拜,
一般公司都理解这不是你的错,所以都还比较flexible... |
|
发帖数: 1 | 37 if expired, then you can't, since new company need you provide proof of
employment status, to do I9, you need to wait for new card
if your card is not expired. then go head, nothing for the company to do
: What is the expiration date of your current EAD? Date1
: What is the receipt date of your 485 EAD extension application?
Date2
: * If Date2 |
|
w*******8 发帖数: 336 | 38 date1和2可以combine啊,不矛盾,更无敌。 |
|
|
|
|
i**********p 发帖数: 1341 | 42 我没说javascript library有bug,我说的是usatt网站的bug. more specifically:
1. javascript library interface design很误导,month从开始,day从1开始,这是
不坑人是什么
2. 注意我post的title是"usatt league网站的bug"。usatt网站没有意识到month从0开
始,默认从1开始,这个inconsistency是个bug
FYI,bug出在usatt网站的dateStringCompare里用了
var date1 = new Date(year1, month1, day1);
var date2 = new Date(year2, month2, day2);
我几个小时之前给他们写信后,建议了fix (把month -1)。他们承认了这个问题,号称
已经fix了,你可以去check dateStringCompare是不是修正了(我没去check过)。估
计你试的时候已经是after fix了,所以正常。
// 这和浏览器无关。大浏览器的javascript int... 阅读全帖 |
|
r**********9 发帖数: 19633 | 43
还是以前那个。。我都date1年多了,倒霉透了
不过,我会有新人的。。。。 |
|
b******s 发帖数: 5365 | 44 估计你会不甘心,你还没折腾完。等折腾得差不多了,你见到那个人就会觉得是合适的
人,不会有“尚可”或者将就的感觉。你还是再date1,2年吧。 |
|
e***t 发帖数: 1 | 45 Use DateDiff function for the first one:
datediff(hh, date1, date2)
use decimal or numeric for the second one, you can declare it as
decimal(10,2) |
|
H******6 发帖数: 51 | 46 MS SQL, use cursor to do this. It works.
Use Test2
go
Declare WebAd_cursor cursor
STATic
For
Select Website,StartDate,EndDate,totalAmount,DaylyAmount
from WebAds1
declare @Website varchar(50),
@StartDate date,
@EndDate date,
@totalAmount float,
@DailyAmount float
Open WebAd_cursor
IF @@CURSOR_ROWS>0
Begin
Fetch next from WebAd_cursor into
@Website ,
@StartDate ,
@EndDate ,
@totalAmount ,
@DailyAmount
while @@FETC... 阅读全帖 |
|
d***e 发帖数: 793 | 47 大概是这样
select date, sum(spend)
(
select t2.date, t1.date date1, date_diff(t1.date, t2.date) diff, t1.spend
from t2
left join t1 on t2.date< t1.date
)a
where diff <30
group by date |
|
d*r 发帖数: 238 | 48 I am working on an asp.net application using c#.
It queris a database and shows the query result as a line of title followed by
a table ( I used Label + DataGrid).
For example, for a Sale database, the web form shows
Date: (in a Label)
Sales: (in a DataGrid)
Now, the user wants to query more than one date and shows the result in one
web form which looks like:
Date1:
Sales1:
Date2:
Sales2:
Date3:
Sale3
...
Since I don't know how many dates the user want to query, I cannot fix the
design the of we |
|
|
p****r 发帖数: 165 | 50 is there a way to find a corresponding function in c/c++ that could count
calendar year/month , which is similar to YEARFRAC(Date1,Date2,1)? Thanks. |
|