cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Stokes
Level IV

How to save a file with name as a variable in For loop to save multiple files

Hi, I am trying to save files in a for loop, the problem is how to put a variable into the file saving procedure,

However, it looks the file save part is not working.

I didn't use any clear global to make sure filename has be assigned with the original value.

Is there any problem with my saving part?

Thanks

 

 

// filename is a variable assigned below,
For( j = 1, j <= N Row( sdt ), j++,
filename = Column( sdt, "file" )[j];
Close( Data Table( sdt ), No Save );

// During saving the file, the directory is fixed, however the filename is an variable, 
// the goal is to use the left(filename,18) and concatenate with "_Type1" in the file name. dt1 = Current Data Table(); dt1 << save( "C:\Users\file\JSL\"||Right( filename,18)||"_Type1.csv" );



2 REPLIES 2
Mauro_Gerber
Level V

Re: How to save a file with name as a variable in For loop to save multiple files

Hi

I chanched the code a bit so this may help:

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

path = "C:\Users\file\JSL\"


For( j = 1, j <= N Row( dt ), j++,
	dt << save as (path || dt:name[j] || "_Type1.csv" );
);

It can be that you need to do a  "save as" to make it work.

"I thought about our dilemma, and I came up with a solution that I honestly think works out best for one of both of us"
- GLaDOS
Stokes
Level IV

Re: How to save a file with name as a variable in For loop to save multiple files

Hi, Thanks a lot.

It works now.

Recommended Articles