I'm stumped here. I have this measure.
Contains = IF(CONTAINS(Flags, Flags[FlagsConcat], SELECTEDVALUE(SlicerFlags[FlagNames])),1,-1)
The concatenated column looks something like this
Flags
id Bco Nat Gur Ga An Sim Oak Ort FlagsConcat
1826 0 0 0 0 0 0 1 1 Oakpoint,Orthoselect
1784 0 0 0 0 0 0 1 1 Oakpoint,Orthoselect
1503 0 0 0 1 0 0 0 0 Guardian
1502 0 0 0 1 0 0 0 0 Guardian
1500 0 0 0 1 0 0 0 0 Guardian
1499 0 0 0 1 0 0 0 0 Guardian
1326 0 0 0 1 0 0 0 0 Guardian
925 0 0 0 1 0 0 0 0 0 Guardian
and here is the values I am grabbing from the selectedvalue()
FlagNames
Benco
National
Guardian-Simply Clear
Guardian
Angel Align
Simply Clear
Oakpoint
Orthoselect
None
If I select Guardian in the slicerFlags table then I get a return value of 1 but if I select either Oakpoint or Orthoselect then I get a -1 even those there are 2 rows in the table that have either word in the FlagsConcat column. I tried putting spaces before and after the comma but that made no difference. Anyone know why the contains() function isn't showing true when looking for Oakpoint or Orthoselect? Thanks in advance.
#Jeroen's code is correct...
Contains = COUNTROWS(FILTER(Flags, CONTAINSSTRING(Flags[FlagsConcat], SELECTEDVALUE(SlicerFlags[FlagNames]))))+0
Related
-2 -1 0
-1 1 1
0 1 2
This is 3x3 emboss kernel. How should I write this in 5x5?
As I understand, these filters take directional differences (see the wikipidea page).
We can decompose you filter into directions
0 -1 0 0 0 0 -2 0 0
0 0 0 -1 0 1 0 0 0
0 1 0 0 0 0 0 0 2
So, I think you can expand it over these 3 directions giving emphasis
0 0 -1 0 0 0 0 0 0 0 -2 0 0 0 0
0 0 -1 0 0 0 0 0 0 0 0 -2 0 0 0
0 0 0 0 0 -1 -1 0 1 1 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0 0 2 0
0 0 1 0 0 0 0 0 0 0 0 0 0 0 2
So, the final kernel would be
-2 0 -1 0 0
0 -2 -1 0 0
-1 -1 1 1 1
0 0 1 2 0
0 0 1 0 2
May be you can also try interpolating filter coefficients marked as x
-2 x -1 0 0
x -2 -1 0 0
-1 -1 1 1 1
0 0 1 2 x
0 0 1 x 2
The simple solution to fitting any lower-dimensional convolution kernel into a higher-dimensional matrix of the same rank is to surround it by zero weights. This is especially true when you're dealing with a concept like embossing, which is arguably more interested in immediate vector of change than the rate at which it is changing. That is, for this embossing matrix,
You could equivalently use this in 5 x 5:
Granted, this will get you a different visual effect than anything with any part of the matrix filled in; but sometimes, especially with edge-detection, immediate clarity is more important. We aren't always displaying it. If this were something like a Guassian blur kernel, having a greater range could improve the effect, but embossing isn't that different conceptually from Sobel-Feldman and it may be better to keep it tight.
i have now 250 million lines of text from a database.
I want to highlight only certain values, that are only in the third column.
I use this \b1011(3[1-9]\d[1-9]|[4]\d\d\d|5[0-8][0-3][0-6])\b for highlight all values between 10113101 to 10115836.
Can one exclude the numbers from column 4?
Edit: a column means for me the text between the spaces
1 2 3 4 5 ..... columns
307607 1317011864 10113101 -25 13135611 2700 0 0 0 12 0 0 0 walk029h.rwx
2264 910115836 10114632 -15 20111192 900 0 0 0 11 0 0 0 walk029.rwx
326169 1010523891 10115836 -1 20911192 0 0 0 0 11 0 0 0 walk12h.rwx
38718 826265392 10113628 0 10114603 2700 0 0 0 11 0 0 0 street2.rwx
241512 1317011864 636346 0 10113987 900 0 0 0 12 0 0 0 walk029h.rwx
38718 826266129 10113448 0 10114310 900 0 0 0 10 0 0 0 tree5m.rwx
38718 826266243 10113898 0 10114810 900 0 0 0 10 0 0 0 tree9m.rwx
This pattern will capture the numbers you want in the third column only. Refer to capture group 1 for their values.
^(?:\S+\s){2}\b(1011(?:3[1-9]\d{2}|4\d{3}|5[0-8][0-3][0-6]))\b.*
All I did was modify yours to add the prefix and removed some redundancy.
Hopefully this is a relatively easy question for someone to be able to help me with. I am a newbie to SAS (and programming).
I have a dataset that has numerous variables each measuring time spent at different activities, with approx. 18,000 unique entries.
I need to get the percentage that each of these variables contribute to the total amount of time spent. I know how to do this just not how to make SAS do it.
Here is a screenshot of some of the variables along with the total at the far right. Please let me know if you need anything else.
DomPazz and momo1644 both contributed useful solutions which are contributing to my understanding of SAS. However both solutions covered doing this on a row by row basis suggesting I was unclear about what I am actually trying to achieve. I am trying to get a total for each of the variables and then find the percentage that that total contributes to the overall total. If I was doing this 'by hand' it would be v1_total/overall-total * 100/1.
You need to calculate the row total, calculate all column totals then drive the percentage. The previous answers were calculating the Row totals only.
SAS Code:
data have;
input surfm wskim Outdoorm dancem fishm snkrm tenpm Leisurem totadmin;
datalines;
0 0 0 0 0 0 0 0 180
0 0 0 0 0 0 0 0 180
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 98.75
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 30
0 0 0 0 0 0 0 0 30
0 0 0 0 120 0 0 120 750
0 0 0 0 0 0 0 0 30
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1291.25
0 0 0 0 0 0 0 0 370
0 0 0 15 0 0 0 15 160
;
RUN;
/*Calculate Total time per Row*/
data row_totals;
set have;
total= surfm + wskim + Outdoorm + dancem + fishm + snkrm + tenpm + Leisurem + totadmin;
run;
/*Calcualte Percentages*/
proc sql;
create table want as
select
sum(surfm)/sum(total) format=percent10.2 as surfm,
sum(wskim)/sum(total) format=percent10.2 as wskim,
sum(Outdoorm)/sum(total) format=percent10.2 as Outdoorm,
sum(dancem)/sum(total) format=percent10.2 as dancem,
sum(fishm)/sum(total) format=percent10.2 as fishm,
sum(snkrm)/sum(total) format=percent10.2 as snkrm,
sum(tenpm)/sum(total) format=percent10.2 as tenpm,
sum(Leisurem)/sum(total) format=percent10.2 as Leisurem,
sum(totadmin)/sum(total) format=percent10.2 as totadmin,
sum(total) as total
from row_totals
;
quit;
Output:
surfm=0.00% wskim=0.00% Outdoorm=0.00% dancem=0.44% fishm=3.54% snkrm=0.00% tenpm=0.00% Leisurem=3.98% totadmin=92.04% total=3390
I have a text file like this:
6.2341 -0.4024 -2.0936 Cl 0 0 0 0 0 0 0 0 0 0 0 0
0.1148 -3.7525 1.0392 S 0 0 0 0 0 0 0 0 0 0 0 0
-2.5441 -0.8745 1.3714 F 0 0 0 0 0 0 0 0 0 0 0 0
The format is: columns 1 to 10, 11 to 20, 21 to 30 are x,y,z coordinates in (10.4) format, i.e. length=10, 4 digits after the decimal point; column 31 is always a space; columns 32 to 32 are the atom type; the remaining columns are not important.
However, for some unknown reason, the atom type field is right-shifted by two columns, like this:
6.2341 -0.4024 -2.0936 Cl 0 0 0 0 0 0 0 0 0 0 0 0
0.1148 -3.7525 1.0392 S 0 0 0 0 0 0 0 0 0 0 0 0
-2.5441 -0.8745 1.3714 F 0 0 0 0 0 0 0 0 0 0 0 0
How to use the sed command and regular expression to match these lines and delete the two extra spaces?
sed -r 's/(.{30}) /\1/' will do the trick.
Group the first 30 characters, match two additional spaces, replace the whole with the grouped characters.
If you don't mind using neither sed nor regular expressions you can just use cut to remove the 2 offending characters:
$ cut --complement -c31,32 file
6.2341 -0.4024 -2.0936 Cl 0 0 0 0 0 0 0 0 0 0 0 0
0.1148 -3.7525 1.0392 S 0 0 0 0 0 0 0 0 0 0 0 0
-2.5441 -0.8745 1.3714 F 0 0 0 0 0 0 0 0 0 0 0 0
I'm working on a project with symfony2, doctrine2 and sonata admin bundle.
When i edit field of an entity in a textarea, it saves it in a postgres database with \r carriage return. This is a problem for me as i use this field with java applets and the format must be correct.
Here is an example that satisfy me :
-ISIS- 02210509232D
42 45 0 0 0 0 0 0 0 0 0
1.6288 -9.1522 -0.6175 O 0 0 0 0 0 0 0 0 0
-0.0179 1.3546 0.0193 O 0 0 0 0 0 0 0 0 0
0.4111 -6.3640 1.1717 C 0 0 0 0 0 0 0 0 0
1.3655 -6.8310 0.0373 C 0 0 0 0 0 0 0 0 0
And here is what i get when editing the field of an other one :
Mrv0541 01081315253D \r
\r
9 8 0 0 0 0 999 V2000\r
-0.0166 1.3706 0.0096 N 0 0 0 0 0 0 0 0 0 0 0 0\r
-1.1791 -0.7076 0.0095 N 0 0 0 0 0 0 0 0 0 0 0 0\r
1.1396 -0.6403 -0.0123 N 0 0 0 0 0 0 0 0 0 0 0 0\r
How can i be sure that the field i edit in a textarea will be in the correct format ? (I don't want these \r)
EDIT:
I checked with javascript on the form page and there is no carriage return at all in the text. I disabled the trim for the field in form.
Where can i check if it is symfony2 or doctrine2 that play a role in saving this entity field with carriage return in place of newline character ?