I'm not very proficient at JSL scripting so, as a test, I asked ChatGPT-4 to write a JSL script for me. I used the "Corn, Wheat, Soybean Production" data table from the JMP sample data. My request was:
"I have a dataset to analyze corn, wheat and soybean production. It consists of 5 columns (Year, State, Commodity, Commodity acres planted, and total acres planted). Can you generate a JMP JSL script to analyze this data?"
In response, it generated the JSL script shown below. However, when I run the script, it doesn't execute and there are no error messages. I don't know enough about JSL to know why it's not working.
I'm just curious if any experienced JSL programmers would like to comment on the quality of the ChatGPT script and perhaps point out to me what is not working. Is this script total garbage or is there maybe one small error that, if fixed, would make it work? I did insert the pathnames manually so it's possible that I screwed that up. I am running JMP on a Mac so the pathnames are formatted accordingly.
Here is the script ChatGPT generated:
// Import the data from a JMP file
dt = Open( "$SAMPLE_DATA/crop_production.jmp" );
// Calculate summary statistics for each commodity
commodities = {"corn", "wheat", "soybean"};
For( i = 1, i <= N Items( commodities ), i++,
dt_sum = dt << Summary(
Group( :Commodity ),
Weight( :Commodity acres planted ),
Statistics( Sum, Mean, Min, Max, Std Dev ),
Subsets( :Year, :State )
);
dt_sum << Select Where( :Commodity == commodities[i] );
dt_sum << Save Selected Rows(
"$SAMPLE_OUTPUT/" || commodities[i] || "_summary.jmp",
"jmp"
);
dt_sum << Delete Rows;
);
// Create a scatterplot matrix of the data
dt << Scatterplot Matrix(
Y( :Commodity acres planted, :Total acres planted ),
Group By( :Commodity ),
By( :Year, :State )
);
// Save the scatterplot matrix as an interactive HTML file
dt << Save Interactive HTML(
"$SAMPLE_OUTPUT/scatterplot_matrix.html",
Scatterplot Matrix
);
// Close the dataset
Close( dt, NoSave );