I have a following formula looking at postcode value from one column and comparing it against the range of postecode data in another column. If the postcode exist it will return true and if it does not then it will return the postcode which does not exist. What I also want this formula to do to check if more then one value exist in case of TRUE and if it does then say the number of mathes rather then TRUE. But if only 1 match exist then simply say TRUE.
=IF(ISERROR(MATCH(C8,$P$2:$P$572,0)),C8,"TRUE")
You can use the SumProduct to count multiple matches
=IF(SUMPRODUCT(($P$2:$P$572=C8)*($P$2:$P$572=C8))=0,C8,IF(SUMPRODUCT(($P$2:$P$572=C8)*($P$2:$P$572=C8))=1,TRUE,SUMPRODUCT(($P$2:$P$572=C8)*($P$2:$P$572=C8))))
You can use COUNTIF() in combination with IF:
=IF(COUNTIF($P$2:$P$572, C8)=0, C8, IF(COUNTIF($P$2:$P$572, C8)=1, "TRUE", COUNTIF($P$2:$P$572, C8))
and perhaps reduce the number of COUNTIFs by adding another column.
Related
I would like to creare a variable along with each subject id, variable is ci_em_ti = COUNT “Impaired” values among the following variables: bvmdrt_cutoff, craftivmmt_cutoff, craftpimmt_cutoff, craftvdelt_cutoff, craftpdelt_cutoff, nlairt_cutoff, nlsdt_cutoff, nlldt_cutoff
How should I do this in SAS?
I tried
countc(cats(of bvmdrt_cutoff, craftivmmt_cutoff, craftpimmt_cutoff, craftvdelt_cutoff, craftpdelt_cutoff, nlairt_cutoff, nlsdt_cutoff), "Impaired")`
but it done not work
The function COUNTC() counts the number of times any of the listed characters appear. By searching for Impaired you are searching for the characters: adeiImpr. So one value of "Missing" will contribute 2 into the count since it has two lowercase i's and "Normal" will count as 3 because the letters r,m and a. "Imparied" will count as 8 since all of the characters are in the search list.
The function COUNT() will search for the number of times a substring occurs so you might try that.
Are you sure your values are character strings? If instead they are numbers with a user defined format attached the CATS() function will not use the formatted values. So you will need to search for the codes instead of the decodes.
PS There is no need to add the OF keyword when there is only one variable in the list. Either remove the OF or remove the commas.
You say count in a column but then your function is actually counting for several columns but a single row. Since you haven't provided usable data, I'll use SASHELP.HEART instead.
This shows how to display your values in each column.
proc freq data=sashelp.heart;
table chol_status bp_status weight_status smoking_status;
run;
What I am looking to do is to, within Postgres, search a column for a string (an account number). I have a log table, which has a parameters column that takes in parameters from the application. It is a paragraph of text and one of the parameters stored in the column is the account number.
The position of the account number is not consistent in the text and some rows in this table have nothing in the column (since no parameters are passed on certain screens). The account number has the following format: L1234567899. So for the account number, the first character is a letter and then it is followed by ten digits.
I am looking for a way to extract the account number alone from this column so I can use it in a view for a report.
So far what I have tried is getting it into an array, but since the position changes, I cannot count on it being in the same place.
select foo from regexp_split_to_array(
(select param from log_table where id = 9088), E'\\s+') as foo
You can use regexp_match() to achieve that result.
(regexp_match(foo,'[A-Z][0-9]{10}'))[1]
DBFiddle
Use substring to pull out the match group.
select substring ('column text' from '[A-Z]\d{10}')
Reference: PostgreSQL regular expression capture group in select
Using OpenOffice CALC v4.1.3.
The dataset contains 400,000 rows and I am looking for the rows that are not in sequence order in column B. Column B contains integers from 1,2,3, etc. to the last row of data.
I am trying to set the cells in column-A with the formula as follow:
=IF(B3 = (B2+1);[empty];"BAD SEQUENCE")
I do not want to have the TRUE part to be "" (empty-string).
I want it to be [empty] or [blank] or [null] or [no-value] or [nothing] (using other language words here)
because I want to be able to use the [shift]+[down-arrow] key combination to find the next BAD-SEQUENCE row(s).
When the set of cells is actually [empty] then the [shift]+[down-arrow] navigates to the next "cell-with-value" (if not [empty]).
In this question, I have presented the code to show [empty] but I need the proper OO-CALC representation of [empty] to have empty cells when the if-statement is TRUE.
Your comments and solutions are welcome...thanks John
From https://superuser.com/questions/346873/openoffice-calc-how-to-insert-blank-in-a-formula:
No value will make isblank return true, because C1 will always contain a formula, and isblank literally tests for blanks. Not empty strings, but actual empty cells.
Like ISBLANK, Ctrl+Down considers any formula to be non-empty, regardless of its result.
Instead, do the following workaround:
Use "" as the [empty] value.
Copy column A.
Select an unused column such as column C.
Paste Special, with the Formulas box unchecked.
Alternatively, instead of using formulas, fill column A with values using a macro.
I've tried searching online for the answer to this, but my Google-fu has failed me.
I have an Access database containing records represented by a string. The first 3 characters of that string are a 3-digit representation of the 366-day calendar date on which the record was created (000-366...yes, leap days count).
I'm having trouble coming up with the correct pattern match to include in a query that matches a 3-digit substring that can be between 000 and 366, where you don't lose the significant figures.
I know the query would be something like:
SELECT * FROM myTable WHERE Field1 LIKE "^[0-2]## or 3[0-5]# or 36[0-6]*";
...but I can't find any resource that says, in MS Access, what the "or" operator is. I tried "||" (double pipe) and "|" (single pipe), neither of which worked.
Is there an "or" operator that can be used with a MS Access pattern match?
The LIKE operator in Access is pretty limited, and doesn't support most of the features more 'fully-fledged' regular expression engines provide.
Instead, use multiple conditions in your WHERE clause like this:
SELECT *
FROM myTable
WHERE Field1 LIKE "[0-2]##*" OR
Field1 LIKE "3[0-5]#*" OR
Field1 LIKE "36[0-6]*"
Another alternative is to simply extract the first 3 characters to a string, convert them to an integer and test to see if their value is within the acceptable range.
Why not just pull the first three characters?
SELECT * FROM myTable WHERE CInt(Left(Field1,3)) <= 366
http://www.techonthenet.com/access/functions/datatype/cint.php
I'm trying to find a valid price validation for my needs..
Valid input format (xxx means no maximum length - 0000 means 4 decimal places at maximum):
15,0000
15.0000
150.0000
150,0000
xxxxxxxxxxxx.0000
xxxxxxxxxxxx,0000
15,00
15,1
15.00
15.1
Invalid input format (basically everything that starts by 0):
01.0000
01.00
01
My regular expression so far: ^\$?[1-9][1-9,]*[0-9]\.?[0-9]{0,2}$
Edit 1: Changed my regex for this one: ^\$?[1-9]*[1-9]((\,)|(\.))?[0-9]{0,4}$ but now I need to be able to add 150000000 and it only allows me 150000
EDIT: just saw that you updated the question and added 0 as a valid input. I'll see if I can add that.
How about:
^([1-9].*[,\.][0-9]*)$
This will work on the examples above.
But be careful with input like 15x,001
See it in action
Okay this one seems okay to me
^[^0]\d+(\.|\,)?[0-9]{0,4}$
checked here http://rubular.com/r/97Ra9VS9h4
and yes one more thing if you want to check for one digit numbers also like 1,2 etc
then you can just replace the + with * like this ^[^0]\d*(\.|\,)?[0-9]{0,4}$
What about this one:
^\$?[1-9][0-9]*(,|\.)[0-9]{1,4}$
The first regex makes sure the price doesnt starts with a zero.
Then all numbers are allowed, zero or more numbers.
Then there must be a comma or a point.
Finaly all numbers are allowed, max count is four and minimum one
^[1-9][0-9]*([.,][0-9]{1,4})?$