Business objects error while trying to use "OR" function - function

The formula is found below:
=NoFilter(Count([Same Day];All) Where ([Person Location- Facility (Curr)]="FH ORL") Where ([Order Catalog Short Description]="Physical Therapy For Whirlpool Wound Care Evaluation And Treatment") Or ([Person Location- Nurse Unit (Curr)] InList ("7TWR";"RIO1";"GT12";"GT14";"9TWR";"XTWR";"RIO")))
Error Message: The expression or sub-expression at position 10 in the 'Or' function uses an invalid data type

The structure of your formula is:
Nofilter (xxx) Where (yyy) Or (zzz InList(aaa))
It's complaining because it sees yyy as the only parameter to Where(). The structure should look like:
Nofilter (xxx) Where (yyy Or zzz InList(aaa))
So try:
=NoFilter(Count([Same Day];All) Where ([Person Location- Facility (Curr)]="FH ORL") Where ([Order Catalog Short Description]="Physical Therapy For Whirlpool Wound Care Evaluation And Treatment" Or [Person Location- Nurse Unit (Curr)] InList ("7TWR";"RIO1";"GT12";"GT14";"9TWR";"XTWR";"RIO")))

Related

Best way to output teffects results from Stata to Excel?

I want to output the ATE, std error, and p-value from this code:
teffects aipw (dep_var, logit) (treatment pred1 pred2 pred3)
I used this code:
putexcel set "$root/filename.xlsx", sheet("5") modify
putexcel A1=`e(stat)'
but it says "ate not found." Shouldn't the ate be stored automatically in e(stat)?
e(stat) stores the statistic that is estimated as a string, i.e. "ate" or "pomeans". This doesn't contain the actual point estimate.
The coefficients and standard errors can be accessed after any estimation command with the following syntax: _b[coef], _se[coef] or [eqno]_b[coef]/_b[eqno:coef] and [eqno]_se[coef]/_se[eqno:coef] in the case of multiple equation models.
You can specify the coeflegend option to most estimation commands to see how coefficients are named.
Example:
. webuse cattaneo2
(Excerpt from Cattaneo (2010) Journal of Econometrics 155: 138-154)
. teffects aipw (bweight prenatal1 mmarried mage fbaby) (mbsmoke mmarried c.mage##c.mage fbaby medu, probit), coeflegend
Iteration 0: EE criterion = 4.629e-21
Iteration 1: EE criterion = 1.939e-25
Treatment-effects estimation Number of obs = 4,642
Estimator : augmented IPW
Outcome model : linear by ML
Treatment model: probit
----------------------------------------------------------------------------------------
bweight | Coef. Legend
-----------------------+----------------------------------------------------------------
ATE |
mbsmoke |
(smoker vs nonsmoker) | -230.9892 _b[ATE:r1vs0.mbsmoke]
-----------------------+----------------------------------------------------------------
POmean |
mbsmoke |
nonsmoker | 3403.355 _b[POmean:0.mbsmoke]
----------------------------------------------------------------------------------------
. di _b[ATE:r1vs0.mbsmoke]
-230.9892
. di _se[ATE:r1vs0.mbsmoke]
26.210565
Any other statistics can be obtained from r(table), type matrix list r(table) after the estimation command to see this. For example, to obtain the pvalue:
mat A = r(table)
scalar pval = A[4,1]
di pval

eclipselink hangs on bind

My EclipseLink JPA (Version 2.6.4) keeps hanging on bind every once in a while on a straight forward select * from entity call.
The OS is an Ubuntu Linux running a mySQL database. The OS, JPA and mySQL version has changed a few times over the last 3 years but the error still happens more often than not. The software currently runs in a Tomcat container.
Here is an excerpt from the code:
String sql="SELECT e FROM " + entityName +" e";
LOGGER.log(Level.INFO,sql+"["+this.getPuName()+"]");
EntityManager em = getEntityManager();
Query query = em.createQuery(sql,this.getEntityType());
query.setMaxResults(maxResults);
result = query.getResultList();
In the log this leads to:
INFORMATION: SELECT e FROM Person e[com.bitplan.smartcrmRest]
[EL Fine]: sql: 2017-08-28 09:57:55.472--ServerSession(509447780)--Connection(1675227444)--Thread(Thread[http-bio-8090-exec-29,5,main])--SELECT PersonNummer AS a1, EMailStatus AS a2, OEGruppe AS a3, PLZPrivat AS a4, AdressStatus AS a5, akademischerTitel AS a6, aktuelleAuswahl AS a7, Anrede AS a8, Art AS a9, card AS a10, createdAt AS a11, DatenHerkunft AS a12, deletedAt AS a13, email AS a14, EntscheidungsFunktion AS a15, ErstelltVon AS a16, FaxPrivat AS a17, Geburtstag AS a18, Gruppe AS a19, Kommentar AS a20, lastModified AS a21, mailinglists AS a22, Mobiltelefon AS a23, Name AS a24, OrganisationsEinheit AS a25, OrtPrivat AS a26, otheremail AS a27, perDu AS a28, photo AS a29, PositionGruppe AS a30, Rolle AS a31, Sachbearbeiter AS a32, salesEstimate AS a33, salesRank AS a34, sex AS a35, socialLinks AS a36, Sprache AS a37, StrassePrivat AS a38, subid AS a39, TelPrivat AS a40, Telefax AS a41, Telefon AS a42, Titel AS a43, Verhaeltnis AS a44, Vorname AS a45, Wichtigkeit AS a46, MEINEORGANISATION_OrganisationNummer AS a47 FROM Person LIMIT ?, ?
bind => [0, 100000]
and then nothing happens. The behavior seems to depends on the amount of records being returned. We see this hang at some 50.000 records up regularly but it also happens with as few as 200 records. The hang is independent of the table being queried.
I have filed a bug report at https://bugs.eclipse.org/bugs/show_bug.cgi?id=521453
Others have experiences similar issues see e.g.
EclipseLink lazy loading hangs on reference class
This topic has been discussed earlier at
https://stackoverflow.com/questions/28297266/eclipselink-jpa-hangs-on-bind
and got some interest by the community.
Due to a mistake of mine there was a misunderstanding and the question has been deleted (see quite lively discussion at My question got deleted by a moderator; how can I find out the reason?).
This is a restart with the intention to also provide
a Minimal, Complete, and Verifiable example see https://stackoverflow.com/help/mcve
So my question would be - what is a good way to make this reproducible?
My first thought would be to provide a Docker container using JPA, mySQL and some dummy data and try to get the same issue. What else might be a good approach?
Addendum 2017-12-10: As a hint the following thread dump information might help.
Searching for the mentioned ConcurrencyManager I found e.g.
https://www.eclipse.org/forums/index.php/t/524575/
Thread dump
"http-bio-8090-exec-22" #46 daemon prio=5 os_prio=0 tid=0x00007f1fdc070800 nid=0x1287 waiting on condition [0x00007f1fe7dfa000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at org.eclipse.persistence.internal.helper.ConcurrencyManager.releaseDeferredLock(ConcurrencyManager.java:445)
at org.eclipse.persistence.internal.identitymaps.CacheKey.releaseDeferredLock(CacheKey.java:458)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:1069)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:898)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:851)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:734)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:688)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:803)
at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:897)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:516)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1174)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1133)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:403)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1221)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1802)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1784)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1749)
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:469)
at com.bitplan.storage.sql.JPAEntityManager.findAll(JPAEntityManager.java:260)
at com.bitplan.resthelper.ManagerResourceImpl.getAll(ManagerResourceImpl.java:161)
at org.eclipse.persistence.internal.helper.ConcurrencyManager.acquire(ConcurrencyManager.java:80)
- locked <0x000000009d300db0> (a org.eclipse.persistence.internal.identitymaps.HardCacheWeakIdentityMap$ReferenceCacheKey)
at org.eclipse.persistence.internal.identitymaps.CacheKey.acquire(CacheKey.java:132)
at org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap.acquireLock(AbstractIdentityMap.java:108)
at org.eclipse.persistence.internal.identitymaps.IdentityMapManager.acquireLock(IdentityMapManager.java:157)
at org.eclipse.persistence.internal.sessions.IdentityMapAccessor.acquireLock(IdentityMapAccessor.java:99)
at org.eclipse.persistence.internal.sessions.IdentityMapAccessor.acquireLock(IdentityMapAccessor.java:90)
at org.eclipse.persistence.internal.sessions.AbstractSession.retrieveCacheKey(AbstractSession.java:5157)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:964)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:736)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:688)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:803)
at org.eclipse.persistence.queries.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:554)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1174)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1133)
at org.eclipse.persistence.queries.ReadObjectQuery.execute(ReadObjectQuery.java:431)
at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3212)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1802)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1784)
at org.eclipse.persistence.internal.indirection.NoIndirectionPolicy.valueFromQuery(NoIndirectionPolicy.java:326)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRowInternal(ForeignReferenceMapping.java:2328)
at org.eclipse.persistence.mappings.OneToOneMapping.valueFromRowInternal(OneToOneMapping.java:1848)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRow(ForeignReferenceMapping.java:2178)
at org.eclipse.persistence.mappings.ForeignReferenceMapping.readFromRowIntoObject(ForeignReferenceMapping.java:1505)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:461)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:1004)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:898)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:851)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:734)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:688)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:803)
at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:897)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:516)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1174)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1133)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:403)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1221)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1802)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1784)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1749)
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:469)
at com.bitplan.storage.sql.JPAEntityManager.findAll(JPAEntityManager.java:260)
at com.bitplan.resthelper.ManagerResourceImpl.getAll(ManagerResourceImpl.java:161)
In the meantime I suspect that
ConcurrencyManager.releaseDeferredLock
is the culprit.
see e.g.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=389227
https://bugs.eclipse.org/bugs/show_bug.cgi?id=464105
https://bugs.eclipse.org/bugs/show_bug.cgi?id=440085

sqldf query returns 0 values

I am having an issue running a basic query on a sample dataset(link below)
http://kbcdn.tableausoftware.com/data/Superstore.xls
using R.
I have attached my code below.
#read file with XLConnect
path <- file.path("/Users/petergensler/Desktop/Sample - Superstore Sales.xls")
superstore <- readWorksheetFromFile(path, sheet= "Orders")
#Query
test <- sqldf("SELECT * FROM superstore WHERE 'Product Sub-Category' = 'Appliances'",)
test
The query executes fine, but it returns the following results:
[1] Row.ID Order.ID Order.Date Order.Priority Order.Quantity Sales
[7] Discount Ship.Mode Profit Unit.Price Shipping.Cost Customer.Name
[13] Province Region Customer.Segment Product.Category Product.Sub.Category Product.Name
[19] Product.Container Product.Base.Margin Ship.Date
<0 rows> (or 0-length row.names)
Is there something wrong with my attached packages that would be causing the query to run wrong, or is it something with my data? the column I am querying on seems to be fine, as it is a type character, and specifying a literal string should match the values(unless their is trailing whitespace), correct?
I am running R on Mac OS X 10.11.5 with the following session info:
session_info()
Session info -------------------------------------------------------------------------------------------
setting value
version R version 3.3.0 (2016-05-03)
system x86_64, darwin13.4.0
ui RStudio (0.99.896)
language (EN)
collate en_US.UTF-8
tz America/Chicago
date 2016-06-08
I have also attached my packages attached to the current session as well.
https://drive.google.com/open?id=0Bxhxg_yftHNubEc4NUZTUVoxa0E
Thanks for your help!
Following up on what G. Grothndieck said (use brackets for column names) I ran this and it worked for me:
#Query
test <- sqldf(x = "SELECT * FROM superstore WHERE [Product.Sub.Category] = 'Appliances'")
test
Most methods of reading in Data frames change spaces and hyphens in column names into . so you need to update that part of it.

Mysql showing type error in python

I wrote the following code to write into mysql database. It shows "%d format: a number is required, not str"
whereas when I print number, it shows 6. why so ??
for i in range(len(text1)):
try1="INSERT INTO `crawl_url_attribute_css_sel_value`(`crawl_item_id`,`crawl_url_attribute_css_sel_id`,`value`,`reconciled`)\
VALUES(%s,%d,%s,FALSE) "
values=(prodlist[i].get_attribute(result1[4]), int(number), db.escape_string(text1[i].text))
print number
cursor.execute(try1,values)
db.commit()
You have to use %s placeholder.
for i in range(len(text1)):
try1="INSERT INTO `crawl_url_attribute_css_sel_value`
(`crawl_item_id`, `crawl_url_attribute_css_sel_id`, `value`, `reconciled`)\
VALUES(%s,%s,%s,FALSE)"
values=(prodlist[i].get_attribute(result1[4]), int(number), db.escape_string(text1[i].text))
print number
cursor.execute(try1,values)
db.commit()
You can read the explanation here
To perform a query, you first need a cursor, and then you can execute
queries on it:
c=db.cursor() max_price=5 c.execute("""SELECT spam, eggs, sausage FROM
breakfast
WHERE price < %s""", (max_price,))
In this example, max_price=5 Why, then, use %s in the string? Because
MySQLdb will convert it to a SQL literal value, which is the string
'5'. When it's finished, the query will actually say, "...WHERE price
< 5".

Rpy2 - Select Results and Output to CSV File

I'm currently doing Cox Proportional Hazards Modeling using Rpy2 - I imagine my question will cover other functions and the results from calling them as well though.
After I run the function, I have a variable which contains the results from the function, in the form of a vector. I have tried explicitly converting this to a DataFrame (resultsDataFrame = DataFrame(resultVector)). There are no errors returned when doing this. However, when I do resultsDataFrame.to_csvfile(filename) I get the following error:
Traceback (most recent call last):
File "<pyshell#171>", line 1, in <module>
modelFrame.to_csvfile('/Users/fortylashes/Documents/Matthews_Research/Cox_PH/ResultOutput_Exp1.csv')
File "/Library/Python/2.7/site-packages/rpy2/robjects/vectors.py", line 1031, in to_csvfile
'col.names': col_names, 'qmethod': qmethod, 'append': append})
RRuntimeError: Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) :
cannot coerce class ""coxph"" to a data.frame
Furthermore, when I simply do:
for result in resultVector:
print (result)
I get an extremely long list of results- including information on each entry in the dataset used in the model, for each variable (so 9,000 records x 9 variables = 81,000 unneeded results). The results I really need are at the bottom of this vector and look like this:
coef exp(coef) se(coef) z p
age_age6574 -0.057775 0.944 0.05469 -1.056 2.9e-01
age_age75plus -0.020795 0.979 0.04891 -0.425 6.7e-01
sex_female -0.005304 0.995 0.03961 -0.134 8.9e-01
stage_late -0.261609 0.770 0.04527 -5.779 7.5e-09
access -0.000494 1.000 0.00069 -0.715 4.7e-01
Likelihood ratio test=36.6 on 5 df, p=7.31e-07 n= 9752, number of events= 2601
*NOTE: There were several more variables for which data was reported in the initial results (the 9,000 x 9 that I was talking about) but weren't actually used in the model.
I was wondering if there was a way to explicitly get this data, put it in one long ordered row, and then output it to a csv file?
::::UPDATE::::
When I call theModel.names I get a list of the various measures which can be called by numerical index:
[1] "coefficients" "var" "loglik"
[4] "score" "iter" "linear.predictors"
[7] "residuals" "means" "concordance"
[10] "method" "n" "nevent"
[13] "terms" "assign" "wald.test"
[16] "y" "formula" "call"
From this I can get the coefficients, which can then be exponentiated. I have not found, however, the p-value, the z score or the likelihood test ratio, which I will need.