Subscribe Bookmark RSS Feed

JMP vs. SAS

edzard_van_sant

Community Trekker

Joined:

Jun 4, 2014

I am a long-time SAS user who uses macro variables to act as placeholders for strings repeatedly used in a program such as path, filename, array columns, etc.

Does JSL have similar functionality?

A couple examples would be greatly appreciated.

4 REPLIES
ian_jmp

Staff

Joined:

Jun 23, 2011

The SAS language and JSL are very different in syntax, structure and intent (reflecting the very different nature of the SAS System and JMP).

Probably the closest parallel would be the ability to define functions in JSL, with the arguments being passed being analogous to the values of macro variables. An example might be:

NamesDefaultToHere(1);

// Given a table and a column therein, makes a Distribution and returns a reference to

// the resulting object

doDistribution =

Function({inTable, inCol}, {Default Local},

thisDistribution = inTable << Distribution(Column(inCol))

);

// Open a table

dt = Open("$SAMPLE_DATA/Big Class.jmp");

// Make a distribution and close it

myDistribution = doDistribution(dt, Column(dt, "height"));

Wait(3);

Report(myDistribution) << closeWindow;

Wait(3);


// Make two distributions and close them in the reverse order

dist1 = doDistribution(dt, Column(dt, "weight"));

Wait(3);

dist2 = doDistribution(dt, Column(dt, "height"));

Wait(3);

Report(dist2) << closeWindow;

Wait(3);

Report(dist1) << closeWindow;

Given the title of the thread, I feel obligated to also mention that there is no sense in which SAS and JMP are in opposition. Indeed, JMP and SAS interoperate very well, when the use case to hand demands it.

edzard_van_sant

Community Trekker

Joined:

Jun 4, 2014

Thanks, Ian. That pointed me in the right direction.

I am using JMP and SAS in complementary fashion.

ian_jmp

Staff

Joined:

Jun 23, 2011

Also. be aware that you can put blocks of code into expressions (which could be put into external files and 'included' if need be). Then you can use 'Substitute()':

Names Default To Here( 1 );

codeBlock = Expr(Print("Macro Variable is "||Char(a%)));

Eval(Substitute( NameExpr(codeBlock), Expr(a%), 10 ));

Eval(Substitute( NameExpr(codeBlock), Expr(a%), 20 ));

erichill

Staff

Joined:

Oct 1, 2013

Here is a simpler example that more directly addresses the idea of a placeholder for strings.  So no direct equivalent of SAS macro variables, but you can accomplish the same thing with JSL variables doing your own concatenation using the "||" concatenation operator ("+" is not used to concatenate strings in JMP):

  path = "c:\users\public\temp\";

  dt1 = Open( path || "bc_mcv.jmp" );

  dt2 = Open( path || "airports_by_state.jmp" );

Hope this helps.

Eric