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;