replace 0 into dash in Fast Report - delphi

Is it Possible to replace 0 value and turn it into dash in fast report?
like:
No. turns to
1 1
2 2
0 -
3 3
0 -
0 -

Yes.
Use a built-in script engine.
Assuming you have a dataset DS and a field FIELD_NAME then instead of [DS."FIELD_NAME"] you should write [IIF(<DS."FIELD_NAME"> = 0, '-', <DS."FIELD_NAME">)] as your frxMemoView text.

Related

Combine variables in order to create new one

I need to have a new variable ethnicity.
The variables that I have now:
Dutch (if yes = 1, if no = 0)
Russian (if yes = 2, if no =0)
So it looks like that now:
Russian Dutch
2 0
0 1
0 1
2 0
How can I combine "Dutch"and "Russian"variables into new one Ethnicity"?
I want to have this result:
Ethnicity
2
1
1
2
I have tried to it with compute, but it was not successful.
The simple\basic\generic approach is:
if dutch=1 ethnicity=1.
if russian=2 ethnicity=2.
But if I understand the structure of your data right, this should also work:
compute ethnicity=sum(dutch, russian).

Problems filling an array with numbers

I created an array and wanted to fill it with numbers. I used a loop but it spoils the previous item when goes to next:
create mass 2 2 * CELLS ALLOT
: [!] ( value index array -- ) + ! ;
: show
4 0 DO mass I + ? LOOP ;
: fill
4 0 DO I I mass [!] show CR LOOP ;
fill
3 3 mass !
show
...so show-word gives me this step by step:
0 0 0 0
256 1 0 0
131328 513 2 0
50462976 197121 770 3
moreover, after 3 3 mass ! the show-word gives me this:
3 0 0 0 ok
I don't understand how to work with arrays and what happens in my loop and why after 3 3 mass ! it gives me not what I get in loop.. please help.
(I understand that forth section is all in my questions now... sorry)
That + word in [!] and show will simply add the index as a number to the address, producing new address that is not aligned to the cell size. This is why you damage the content of mass, and also you don't see its content with show correctly.
Without changing much the stack effects of your words, the fix could look like this:
create mass 2 2 * CELLS ALLOT
: [!] ( value index array -- ) swap cells + ! ;
: show
4 0 DO mass I cells + ? LOOP ;
: fill
4 0 DO I I mass [!] show CR LOOP ;
fill
3 3 mass [!]
show
Note the cells word that will transform the index into correctly sized offset into the array.
edit: in the last manual assignment use your [!] word, or transform the index 3 into correct offset, as mentioned by #dave_thompson_085 in the comments.

Performing exact match when comparing variables in SPSS Statistics

I'm wondering if there's a way for me to perform an exact match compare in SPSS. Currently, using the following will return system missing (null) in cases where one variable is sysmis:
compute var1_comparison = * Some logic here.
compute var1_check = var1 = var1_comparison.
The results look like this (hypens representing null values):
ID var1 var1_comparison var1_check
1 3 3 1
2 4 3 0
3 - 2 -
4 1 1 1
5 - - -
What I want is this:
ID var1 var1_comparison var1_check
1 3 3 1
2 4 3 0
3 - 2 0
4 1 1 1
5 - - 1
Is this possible using just plain SPSS syntax? I'm also open to using the Python extension, though I'm not as familiar with it.
Here's a slightly different approach, using temporary scratch variables (prefixed by a hash (#)):
recode var1 var1_comparison (sysmis=-99) (else=copy) into #v1 #v2.
compute Check=(#v1 = #v2).
This is to recreate your example:
data list list/ID var1 var1_comparison.
begin data
1, 3, 3
2 , 4, 3
3, , 2
4, 1, 1
5, ,
end data.
Now you have to deal separately with the situation where both values are missing, and then complete the calculation in all other situations:
do if missing(var1) or missing(var1_comparison).
compute var1_check=(missing(var1) and missing(var1_comparison)).
else.
compute var1_check = (var1 = var1_comparison).
end if.

SPSS counting changes between variables

I have a dataset that has three variables which indicate a category of event at three time points (dispatch, beginning, end). I want to establish the number of cases where (a) the category is the same for all three time points (b) those which have changed at time point 2 (beginning) and (c) those which have changed at time point 3 (end).
Can anyone recommend some syntax or a starting point?
To measure a change (non-equivalent) against T0 (Time zero or in your case Dispatch), wouldn't you simply check for equivalence between respective variables?:
DATA LIST FREE /ID T0 T1 T2.
BEGIN DATA.
1 1 1 1.
2 1 1 0.
3 1 0 1.
4 0 1 1.
5 1 0 0.
6 0 1 0.
7 0 0 1.
8 0 0 0.
END DATA.
COMPUTE ChangeT1=T0<>T1.
COMPUTE ChangeT2=T0<>T2.
To check all the values are the same across all three variables would be just (given you have string variables else otherwise you could do this differently if working with numeric variables such as Standard deviation):
COMPUTE CheckNoChange=T0=T1 & T0=T2.

How to repeat a case value until a different value is encountered?

I currently have a data file that is structured like this:
1
-
-
2
-
3
-
I would like it to look like this:
1
1
1
2
2
3
3
Unfortunately I do not how to achieve this in SPSS. Is there are a simple command that could recode the data this way?
I have found the answer, by using the LAG function. (I defined 9999 as a missing value).
IF (variable = 9999) variable=LAG(variable).
EXECUTE.

Resources