BookmarkSubscribeRSS Feed
hellohere
Pyrite | Level 9

I have a setting file, the top two lines are below(it have 10+ lines).

Need to update the sinx_index value with a macro variable from SAS run. 

How to do it?! Any convenient way, thanks, 

 

[global]
sinx_index=100

 

3 REPLIES 3
hellohere
Pyrite | Level 9
the setting filename is: config_sinx.ini
Patrick
Opal | Level 21

Using SAS you would have to read the external file into a table with a single SAS variable, then change the value of this variable the way you need it and then write back to an external file (=replacing the external file).  Having said that: It feels sort of wrong to change an .ini file with a (SAS) script. Is this really something you need to do regularly? 

Also be aware that when re-creating the file it likely will have changed ownership and permissions which is another reason that I'm not so sure about your idea for a .ini file.

Many .ini files get only processed when an application starts so your changes might not take effect immediately. Have you already tried what happens if you change the value manually?

 

Can you please explain a bit more in-detail what this is about? If you really need this then I would eventually not use SAS (or only use SAS to call some OS commands that are doing the job). With such an approach we would also need to know your OS (Unix, Linux, Windows?) and if SAS option XCMD is set in your environment. 

I couldn't find anything when searching for sinx_index In which context gets this parameter used.

 

Kurt_Bremser
Super User
%let ini_value=100;

data _null_;
infile "/path/config_sinx.ini";
file "/path/config_sinx.ini.new";
input;
if scan(_infile_,1,"=") = "sinx_index"
then put "sinx_index=&ini_value.";
else put _infile_;
run;

data _null_;
rc = filename("fref","/path/config_sinx.ini");
rc = fdelete("fref");
rc = rename("/path/config_sinx.ini.new","/path/config_sinx.ini","file");
rc = filename("fref");
run;

As already mentioned, this will probably change ownership and permissions of the file and make the application unusable. Or it might fail altogether because the user running SAS does not have the necessary permissions for the file or its parent directory.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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