所以,我每個診所的訪問日期都有行。 目前,所有診所就診日期都記錄在“DateSeen”下的同一欄中。相反,我需要為每個患者ID提供一行,我需要為每次訪問創建一個單獨的列(按時間順序排列)。 例如“第一次訪問,第二次訪問,第三次訪問”等,直到第五次訪問。
有人可以幫忙嗎?出於顯而易見的原因,我無法共享實際數據,但這裡有一些虛擬數據。
| ID | DateSeen |
| 8 | 2016年5月3日 |
| 8 | 2015年6月20日 |
| 1 | 2013年12月3日 |
| 10 | 2012/2/28 |
| 9 | 2013年9月13日 |
| 9 | 2014年8月23日 |
| 6 | 2008年7月10日 |
| 3 | 2014年1月1日 |
| 2 | 6/15/2011 |
| 五 | 4/1/2011 |
| 1 | 2014年2月26日 |
| 3 | 二零一六年四月三十日 |
| 1 | 2015年8月6日 |
| 9 | 2009年5月9日 |
| 4 | 2011年10月1日 |
| 2 | 2011年7月23日 |
| 8 | 2013年10月5日 |
| 8 | 2009/1/10 |
| 1 | 2016年8月11日 |
| 9 | 2015年6月6日 |
| 7 | 2014年9月20日 |
| 3 | 2015年11月21日 |
| 2 | 2014年3月1日 |
| 9 | 1/8/2010 |
| 6 | 2015年8月1日 |
| 3 | 2016年8月6日 |
| 3 | 2013年11月9日 |
| 4 | 2011/8/27 |
| 1 | 2014年7月11日 |
| 10 | 2009/10/31 |
| 2 | 2015年4月1日 |
| 2 | 2007年8月11日 |
| 五 | 2014年7月18日 |
| 9 | 2013年10月15日 |
Apparenty我引起了一點混亂。 在我包含的腳本中,我包含了一個步驟,用於創建您在第一個語句中包含的數據表。 我的代碼部分只是為了讓我回复的內容能夠運行一些示例數據。 實際完成工作的腳本部分可以與無限數量的患者一起運行。 所以你需要做的就是創建大數據表,並運行我創建的腳本的最後一部分。 只需確保患者ID列名為“ID”,日期列稱為“日期/看到”。 此外,“日期/已查看”列必須是數字JMP日期列。
// Sort the table so that all visits for a given individual are together
// and in asscending order of the visit date
dt << Sort( By( :ID, :Name( "Date/Seen" ) ), Order( Ascending, Ascending ), Replace table( 1 ) );
// Create a new column which is just a simple counter of the visit number
dt << New Column( "Visit Number",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If( Lag( :ID ) != :ID,
num = 1,
num = num + 1
);
num;
)
);
// Split the data by the visit number
dt << Split(
Split By( :Visit Number ),
Split( :Name( "Date/Seen" ) ),
Group( :ID ),
Sort by Column Property
);
你真了不起!!非常感謝!這讓我很緊張!我希望你下次航班免費升級到頭等艙。 
這是一個簡單的腳本,可以滿足您的需求。 如果您按照腳本中的步驟操作,則可以輕鬆地以交互方式執行這3個操作
Names default to here( 1 );
// Input the original data table
dt = New Table( "Patient Visits",
Add Rows( 34 ),
New Column( "ID",
Character,
"Nominal",
Set Values(
{"8", "8", "1", "10", "9", "9", "6", "3", "2", "5", "1", "3", "1", "9", "4", "2", "8", "8", "1",
"9", "7", "3", "2", "9", "6", "3", "3", "4", "1", "10", "2", "2", "5", "9"}
)
),
New Column( "Date/Seen",
Numeric,
"Nominal",
Format( "m/d/y", 12 ),
Input Format( "mmddyyyy" ),
Set Selected,
Set Values(
[3545078400, 3517603200, 3468873600, 3413232000, 3461875200, 3491596800, 3298492800, 3471379200,
3390940800, 3384460800, 3476217600, 3544819200, 3521664000, 3324672000, 3400272000, 3394224000,
3463776000, 3314390400, 3553718400, 3516393600, 3494016000, 3530908800, 3476476800, 3345753600,
3521232000, 3553286400, 3466800000, 3397248000, 3487881600, 3339792000, 3510691200, 3269635200,
3488486400, 3464640000]
)
)
);
// Sort the table so that all visits for a given individual are together
// and in asscending order of the visit date
dt << Sort( By( :ID, :Name( "Date/Seen" ) ), Order( Ascending, Ascending ), Replace table( 1 ) );
// Create a new column which is just a simple counter of the visit number
dt << New Column( "Visit Number",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If( Lag( :ID ) != :ID,
num = 1,
num = num + 1
);
num;
)
);
// Split the data by the visit number
dt << Split(
Split By( :Visit Number ),
Split( :Name( "Date/Seen" ) ),
Group( :ID ),
Sort by Column Property
);