SAS 到 JSL - 循環...我是長期 SAS 用戶被迫學習 JSL ......
我在 SAS 中發現容易的事情在 JSL 中似乎很困難......
有人可以通過與我分享將使用 JSL 生成以下嵌套循環表的 JSL 代碼,向我展示循環在 JSL 中如何工作嗎?
數據挫折;
做 temp = 1 to 10 by 1;
按 = 5 到 20 乘 5;
做時間 = 1 到 1000 乘 20;
輸出;
結尾;
結尾;
結尾;
跑;
創建這些類型的模擬應該相當簡單,但我似乎無法弄清楚這一點。
腳本回复:SAS 到 JSL - 循環...您來對地方了,可以幫助您學習 JSL。腳本索引是您的朋友,在線文檔也是如此。
這是一個代碼片段,可以滿足您的需求:
dt = data table("frustration");
for (temp = 1, temp <= 10, temp++,
for (press = 5, press <= 20, press+=5,
for (time = 1, time <= 1000, time+=20,
show(temp, press, time); // output
);
);
);
回复:SAS 到 JSL - 循環...所有這些都包含在腳本指南中,我非常非常強烈地建議您閱讀。它位於 JMP 文檔庫中,位於 JMP 的“幫助”下拉菜單中。
回复:SAS 到 JSL - 循環...JSL 的 C++ 程序員指南也可能有一些幫助。 它試圖展示 JSL for 語句是如何真正成為一個函數的,並且知道這將使獲得正確的語法變得容易得多。
回复:SAS 到 JSL - 循環...感謝您的幫助
回复:SAS 到 JSL - 循環...我聽到你在說什麼......謝謝......但是,這有點像有人告訴你閱讀聖經以了解基督教......我在腳本指南中花了大約 2 個小時來尋找如何做到這一點。簡單的概念...此外,我在編寫其他腳本方面也取得了很大的成功...但老實說,腳本指南讓我渴望在預算中額外增加 20k 的 SAS 許可證。
我不是鐵桿程序員... 我是一名工程師,只是想快速完成工作。
回复:SAS 到 JSL - 循環...謝謝...這很有幫助。
回复:SAS 到 JSL - 循環...我發現通過示例學習更容易,因此請盡可能多地查看此論壇中的代碼。一旦你開始,腳本索引將真正成為你的朋友。
JSL為了循環和如果聲明雖然在概念上很簡單,但最初對我來說有點莫名其妙。為了縮短你的學習曲線如果,記住它是一個函數,逗號代表然後,否則如果和別的.打開腳本窗口 ( Ctrl-T ),在窗口中單擊鼠標右鍵並選擇顯示嵌入式日誌.粘貼下面的代碼並點擊Ctrl-R運行它。玩弄 a、b 和 c 的不同值,看看會發生什麼。
a = 1;
b = 2;
c = 1;
if (a == b,
// then
print("a is equal to b");
,
// else if
a == c,
// then
print("a is equal to c");
,
// else
print("No match found for a");
);
回复:SAS 到 JSL - 循環...一個完整的例子,了解開始使用一種新語言是多麼困難。 (幫助->腳本索引和在線幫助是互補資源。 我主要使用幫助->腳本索引來提醒我它是如何工作的。 在線幫助可能更適合開始使用。)我在這裡放了一些比需要的更多的東西。 我忘記了名稱大小寫的 SAS 規則......
Names Default To Here( 1 );
// what does that mean? JSL has several namespaces; the 'here' namespace is for this
// editor window and means 'press' is really 'here:press' but 'dtFrustration:press' belongs to
// the table's namespace (of column names.) You could also just use different names,
// like 'iPress' for the loop control variable. JMP's variable names are almost never
// case sensitive, the weird exception being column names, which are only sensitive <BR />// if both 'Age' and 'age' are columns...Don't do that!
// an easy way to get this table script is to make a new table with the
// JMP GUI, then use the top-left red triangle to 'Copy Table Script (No Data)'.
// By convention, JSL uses 'dt' in the variable name that holds a handle to a table.
dtFrustration = New Table( "frustration",
New Column( "temp" ), // continuous numeric by default
New Column( "press" ),
New Column( "time" )
);
// because the table might be linked to other reports, there
// is a lot of hidden messaging when the table changes. A lot.
// The messaging can be shut off and later enabled for a nice speedup.
// (to see it take longer, rerun just the loop below.)
// dtFrustration << BeginDataUpdate; // pair with EndDataUpdate, below
For( temp = 1, temp <= 10, temp++,
For( press = 5, press <= 20, press += 5,
For( time = 1, time <= 1000, time += 20,
dtFrustration << addrows( 1 );
dtFrustration:time = time;
dtFrustration:temp = temp;
dtFrustration:press = press;
)
)
);
// dtFrustration << EndDataUpdate;
回复:SAS 到 JSL - 循環...再次感謝超級用戶 PMROZ;這很有幫助。