Can't delete sysmis spss variables - variables

Need to delete spss variable without the data (sysmis data)
The command IF(SYSMIS(V1)) DELETE VARIABLES V1. doesnt' work.

The IF command does not work in this way, that you are attempting. It operates on a case by case basis i.e. so IF a case matches a certain criteria THEN apply a certain transformation to THAT CASE ONLY (not a variable as a whole).
If you do not dynamically need to search for empty variables (which is possible with python - see below) then all you need is the DELETE VARIABLES command (or alternatively ADD FILES or MATCH FILES command all achieving exactly the same result - with the exception of DELETE VARIABLES requiring no pending transformations so in which case I personally prefer ADD FILES or MATCH FILES).
Any one of these 3 commands should suffice:
DELETE VARIABLES v1.
ADD FILES FILE=* /DROP=v1.
MATCH FILES FILE=* /DROP=v1.
If however, you need to dynamically check if a variable is empty and then only delete it, then you can use python to do so.
You will need to have python integration installed and correctly setup for your version of SPSS and spssaux2 module downloaded and saved in the appropriate location where SPSS can find it, for the below to work:
DATA LIST FREE / A B C D.
BEGIN DATA
1 2 3 4 5 6 7 8 9 10 11 12
END DATA.
COMPUTE C=$SYSMIS.
DATASET NAME DSSIM.
BEGIN PROGRAM.
import spssaux2
spssaux2.FindEmptyVars(delete=True)
END PROGRAM.

SYSMIS doesn't refers to variables but cells. From your approach you have to ;
COUNT(SYSMIS(V1)) and if its equal to your case(row on data file) count then you can DELETE VARIABLES V1.

Related

SCIP - run (nearly) same LP on different instances

I have an LP, formulated in the modelling language Zimpl, that I want to run on many instances, which are in different files.
Additionally, I want to change one parameter in this LP.
For a single call, my file test.zpl looks like this:
param FILE := "file1.dat"
param BOUND := 42
[test_body: Rest of LP]
Now I want to change those two parameters. SCIP has the -c option, to execute some command. But I cannot find by which command to achieve this. All parameter changes I found affect the algorithm, not the data.
The command change to change the problem does not seem to allow new parameters/variables.
In the end, I expect the solution to look something like
scip -c "[set my parameters]; read test_body.zpl; optimize; quit"
How do I set these problem parameters?
I am not aware of any commands that support the modification of model parameters as you wish. However, if you don't hardcode the value of param BOUND in the .zpl file (instead, move the value to the .dat file and use a proper read command in the model), then you could procede as follows:
Make a copy of your data file such that each copy contains a distinct value of param BOUND
Call scip.exe separately with each data file (you could also use a simple batch script)

Can I create Variable Names from Constants in Objective-C/Swift?

This question is related to Swift and Objective-C.
I want to create variables from Constant Strings. So, in future, when I change name of a variable though out app, I just need to change it at one place, it must be changed, wherever it is used.
Example:
I have user_id in 14 files, if I want to change user_id into userID I have to change in all 14 files, but I want to change at once place only.
One way to do this would be to use the Xcode build process and add a script (language can be of your choice, but the default is a BASH script)
Create string constant text file where you define all your variables you want to change in some format that expresses the change you want to make, for example:
"variable_one_name" = "new_variable_one_name"
Depending on how 'smart' you wanted your script to be you could also list all your variables and include some way of indicating when a variable is not to be replaced.
"variable_one_name" = "new_variable_one_name"
"variable_two_name" = "DO_NOT_CHANGE"
Run a pre build script on you project that reads in the string constant text file and then iterates through your source files and executes the desired replacement. Be careful to limit the directories you search to you OWN source files!
build project...
This would allow you to manage your constants from one place. However it clearly is only going to help you after you have created a project and written some code :)
BASH string replacement
Adding a run script to the Xcode build process

Writing a table to a file using D3 pick

In D3, suppose I have a file called foo and I want to write the contents of the file out to /var/tmp/bar. The documentation leads me to believe that it should be possible to make D3 write the file to the file system by changing the D pointer into a Q pointer, but I can't figure out how to make this happen.
You can do this at least a few ways.
1) You don't want to change a d-pointer to a q-pointer, you just want to create a q-pointer. In other words there's no need to have a d-pointer first to access the host file system. So your q-pointer called 'bar' will look like this:
Q
/var/tmp/bar
With that you can simply:
copy foo
to: (bar
Note that in this case 'bar' is a host OS folder/directory, not a file. A D3 'file' is a table that has multiple records. That translates to a host OS directory with multiple files.
Options are available on the Copy command to suppress the display of item IDs (keys) as records are copied (see docs).
2) You don't even need a q-pointer:
copy foo
to: (/var/tmp/bar
3) Similarly in code you can use the q-pointer or you can use the direct path:
open 'bar' to f.bar1 ...
open '/var/tmp/bar' to f.bar2 ...
==
The path syntax is using a mechanism called the OSFI (see docs). With this syntax you can specify a driver. The default driver called "unix:" converts attribute marks to the *nix EOL which is a line-feed x0A. If you're on Windows the default is "dos:" which converts attribute marks to CRLF x0D0A. You can force a non-default by preceding the path with the driver. So to create a DOS-format file in Unix/Linux, use dos:/var/tmp/bar. The default drivers also convert between tab and 4-spaces (see docs). Values and subvalues are not converted but a new driver can be created to do so. Use the 'bin:' driver to avoid conversions, so bin:/var/tmp/bar will not convert #am (xFE) to x0A, etc.
If you need more detail I'll be happy to add to this.

how to print f[r] and f[k] values in an output file for each value of r and k in mathematica?

How can i print the f[r] and f[k] values in an output file along with r and k values using mathematica?
Is there any way I can automate the export of this output to a .txt file without having to re-write the Print[] commands?
The simplest approach to saving Mathematica expressions is to use the Save function. You could write
Save[filename,x]
and Mathematica will save the definitions associated with variable x into the file you've named. Note
Save appends to an already existing file;
expressions are written in InputForm;
you can load the expressions back into your workspace using the << (aka Get) function, which reads and evaluates the expressions stored in a file.
How you actually use Save to store your data is up to you. You might, perhaps, assign the results of a call such as Table[{k,f[k]},{k,min,max,step}] to a variable and save that result variable, which will appear in the file as a table of k,f[k] pairs.
Since Save appends to an existing file you could, if you are using loops, save a k,f[k] pair at each iteration. But why would you be using loops in Mathematica ?

How to use Reject file in infobright with version 4.0.6 GA

In the release notes of version 4.0.6 GA, we can found that the first new feature is "Infobright Loader now supports a Reject file"
But I cannot find anything more about this, just like how to use it, and in which case we may need it.
Please help
To enable the reject file functionality, you must specify BH_REJECT_FILE_PATH and one of
the associated parameters (BH_ABORT_ON_COUNT or BH_ABORT_ON_THRESHOLD).
For example, if you want to load data from the file DATAFILE.csv to table T but you expects
that 10 rows in this file might be wrongly formatted, you would run the following
commands:
set #BH_REJECT_FILE_PATH = '/tmp/reject_file';
set #BH_ABORT_ON_COUNT = 10;
load data infile DATAFILE.csv into table T;
If less than 10 rows are rejected, a warning will be output, the load will succeed and all
problematic rows will be output to the file /tmp/reject_file. If the Infobright Loader finds a
tenth bad row, the load will terminate with an error and all bad rows found so far will be
output to the file /tmp/reject_file.