SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
wooden
Calcite | Level 5

At work, I've written some Python scripts to pull a bunch of data from our database, save it as a CSV, open it in JMP, and run a JSL script on it to create some graphs and other junk. The problem I'm running into is that I cannot find a way to get the full path to the CSV file within the JSL script.

 

The Python script creates the directory, moves the CSV into it, and then opens the CSV in JMP and immediately runs the JSL script on it. In th Python script, this looks something like:

os.chdir(sJMPLoc) // move to the JMP install dir
subprocess.Popen(sCmdOpen) // execute the command to open the CSV file in JMP
subprocess.Popen(sCmdScript) // execute the command to run the JSL script

 

In the JSL:

dt = Current Data Table();

dt << Save();

 

This didn't appear to work, so I started digging to see where it thought the file was stored and added this to my script:
dir = dt << getpath;
show(dir);

 

Results of that:

dir = "POWER_CORRELATIONS_YESTERDAY_09_08_15__15_36_57.jmp";

Turns out JMP is converting the .CSV into a .JMP file and storing it in some temp directory, or at least the dt << getpath function isn't aware of the original path.

 

How can I get the path to the CSV where the CSV was when it was opened

 

Thanks,

Chip

3 REPLIES 3
Tom
Super User Tom
Super User
If you are generating the JMP code then why not just write the path into the code that you generate?
wooden
Calcite | Level 5

Every time the Python script runs, it creates a new directory for the data and all reports for it. If I could get our database tools to save the file as a JMP file, this would all be easy as JMP retains the path to JMP files:

 

/*:
//:*/
dt = Current Data Table();
show(dt << getpath);
/*:

dt << getpath = "C:\Users\cpwood\Documents\correlationData\power_54W_ww32p1_working.jmp";

 

The same cannot be said about CSVs:

/*:
//:*/
dt = Current Data Table();
show(dt << getpath);
/*:

dt << getpath = "POWER_CORRELATIONS_YESTERDAY_09_04_15__15_36_57.jmp";

 

The POWER_CORRELATIONS_YESTERDAY... file was a CSV when opened, but JMP appears to immediately convert it to a JMP file (reasonably so) and ditch the path for some odd reason.

Jens_Riege
Calcite | Level 5

I am running into the same issue. The reason I did not write the path into the code is because I am trying to automate the process so that the script find the path and then saves a JMP plot in the folder that had the original csv file. I am also having the issue that JMP loses the path that I selected and instead selects the path that points to the script file folder, not the csv file folder... 

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 4245 views
  • 0 likes
  • 3 in conversation