R vs SAS, why is SAS preferred by private companies?

Question: I learned R but it seems that companies are much more interested in SAS experience. What are the advantages of SAS over R?
Comment: @Momo R comes without warranty, true, but I would like to see a reference that SAS has that strong of one. I could not find the SAS license text on their website, but was able to find something for one component: http://support.sas.com/documentation/onlinedoc/sasc/doc650/common/agreement.htm That has a 90 day warranty on the media that the software is shipped on and an all caps disclaimer of any other warranty. Please give a reference other than "someone once told me".
Comment: SAS comes with the same warranty as R: none.
Comment: A medical statistician once told me, that they use SAS because if they make mistakes due to software bugs and it comes to lawsuits, SAS will recompensate them. R comes without warranty.
Comment: It's tragic, but true I fear...
Comment: Was just meant as an anecdote, I like the pragmatic cynicism of the comment. But glad you checked, I never cared.
Comment: After reading lots of the comments/answers, IMO it sounds like the biggest problem here is: "entrenched proprietary software culture" vs "newer open source culture". So the problem boils down to your standard arguments for and against using proprietary software versus using open source software. When people are against open source, I like to give a good counter example for instance: 100s of millions of people depend on linux everyday... ranging from most websites (apache), to most smartphones (android), to most supercomputers (use linux kernel), to many embedded devices.
Comment: ... or you can use R 3.0.0 which has broken past the RAM limits in R and will use the swap/pagefile.
Comment: For my area (government statistics, including population census, with databases of ~ 20G), R simply can't do the job. However, there are divisions that use also R, I believe mainly for econometry.
Comment: @arbautjc If the dataset size is the only problem, you just need a computer with 64+GB of RAM; or you can use `bigmemory` or `ff`.
Comment: I was asked this question and my response was as long as there is still fortran and cobol code out there, sas will exist.  That is the power of legacy code and legacy systems is hard to underestimate !
Comment: I discussed this with some friends on facebook awhile ago, and found two links that were particularly nice on the subject: http://www.linkedin.com/groups/SAS-versus-R-35222.S.65098787 http://www.thejuliagroup.com/blog/?p=1757
Comment: PROC IML has a similar feel to R - and it also has an interface to R available (it requires some kind of install option though).
Comment: Large companies with a history of success tend to set the standards in an industry. SAS has this incumbent advantage, and also benefits that its price creates a large barrier to entry in other industries. This gives large established companies an advantage over smaller new competitors and allows them to charge higher prices due to the restricted competition.
Comment: See also: [is-the-r-language-reliable-for-the-field-of-economics](http://stats.stackexchange.com/questions/25811/).
Comment: A somewhat relevant review: http://www.analyticsvidhya.com/blog/2014/03/sas-vs-vs-python-tool-learn/
Answer: I think there are several issues (in ascending order of possible validity):

Tradition / habit: people are used to SAS, and don't want to have to learn something new.  (Making it more difficult, the way you think in SAS and R is different.)  This can apply to anyone who might have to send you code, or read / use your code, including managers and colleagues.
Distrust of freeware: I've had several people say they aren't willing to accept results from R because you don't have a for-profit company vetting the code to ensure it gives correct results before it goes out to customers, lest they end up losing business.
Big data: R performs operations with everything in memory, whereas SAS doesn't necessarily.  Thus, if your data approaches the limits of your memory, there will be problems.

Personally, I only think #3 has any legitimate merit, although there are approaches to big data that have been developed with R.  The issues with #1 speak for themselves. I think #2 ignores several facts: there is some vetting that goes on with R, many of the main packages are written by some of the biggest names in statistics, and there have been studies that compare the accuracy of different statistical software & R has certainly been competitive.
Comment: Point 1 gains more legitimacy if you also include "existing infrastructure" under that inertia banner. If there are existing business processes which already use SAS, then there is a transition cost with changing. If this is the case, it is not choosing between SAS and R, but choosing between staying with SAS and changing to R, which can have a different conclusion.
Comment: Who exactly vets SAS, Stata, SPSS, code? Is there any way at all to know if the results they provide, by the methods they say they are using, are actually implemented correctly? I know from following, for example, the `lme4` mailing list that comparisons to SAS come up quite regularly. But it's impossible to know if we should even be making such comparisons. Without access to the source, we have to take those companies at their word that results produced by their software are actually valid. Frankly, I prefer to have the ability to review the software code I use.
Comment: True, but it's hard to penalize a statistical computing system for its comprehensiveness.  Or to say it another way, R's way of doing something is better than another system's way of not doing it.
Comment: The point of Point 2 is that, while SOME R packages are written by experts, others are not. Who vouches for them? Who tests them? (I know they are tested that they RUN, but who tests that they work correctly?)
I know, you can look at the code, but that presupposes the time and ability to look over someone else's code and verify it, often for methods that are very complex.
Comment: @PeterFlom, you raise a reasonable point. As the packages become more esoteric, there is less of a guarantee than there is w/ the basic stuff. But how far afield do you have to go? Even SEM, which is pretty advanced, was written in R by John Fox. Additionally, StasK makes a good point about the reality of the vetting of statistical software in practice. Finally, R is vastly more comprehensive than anything else, so when you want to do esoteric things w/ other software, you mostly have to code it up yourself. Who guarantees the accuracy of that code?
Comment: I'm not sold by @PeterFlom 's point either.  There are about 4000 packages in R.  Not all have to be of the highest quality for add-on packages to have a net positive value.  The number of reliable add-on packages exceeds the capabilities of SAS by a huge margin.
Comment: @gmacfarlane: While one certainly can sue SAS for programming negligence, the plaintiff is unlikely to succeed in court. Scroll down to "warranties and disclaimers" in the SAS terms and conditions ( http://www.sas.com/Copyright.html ). By using SAS, you legally enter into a contract explicitly excluding SAS from liability for damages caused by the software. Arguably, R has the advantage here. A statistician may carefully check conclusions from an R analysis, knowing the software comes with no guarantee, but might wrongly presume a legal guarantee from SAS and be overconfident in conclusions.
Comment: Oh, I totally believe that, and have been in these conversations myself. They apparently are not aware of what I said, though. As with pretty much any software, the guarantee is essentially in the law of large numbers: there has been so many users that ran so many regressions that this is most likely right. Otherwise, people would come back and say, "Why Splus and Stata and R and SPSS all give me 1.423590278, and SAS gives me 1.4182340399?" This is usually how statistical software is being debugged in practice.
Comment: #2 is a ficticious argument. There is no written guarantee anywhere that SAS produces correct numbers. The only explicit guarantee is that they will replace the media if your CD-ROM does not read it.
Comment: @Stask et all, I've seen a few examples (though un-referenced) of quite basic errors in SAS that harmed analysis, the one that comes to mind is that numerically it can treat NA as -inf, so a major clinical analysis had logic that if date_stroke < date_last_visit then patient considered to have a stroke, obviously all patients who had NA as stroke date were also conisdered as having a stroke. (possibly from a useR presentation ?)
Comment: Frank (on doing something vs. not doing it), let us not switch the topic: this is not the argument about comprehensiveness, it's an argument about reliability. For research purposes, assuming people using the package have graduate degrees in statistics and understand what they are doing (and throw away bad results when they see them) -- yes, R's thousands of packages is a good thing. For production purposes, and users just pushing buttons without understanding, hell, no freaking way, R's model is a sure way to disaster. Out of 5 packages doing the same thing, which one can be trusted, if any?
Comment: I don't really agree with that perspective but do understand it.  Related to @PaulHurleyuk's comment, this exact problem (even involving time to stroke) occurred in a 40,000 patient randomized clinical trial as published in the New England Journal of Medicine (I may have been the one who mentioned this at a past useR conference).  SAS labels their missing data algebra as a 'feature' but the rest of the world would call this a bug.
Comment: @PeterFlom: see http://www.jstatsoft.org/instructions#review. They say the statistics are reviewed for correctness, and the software must do what the paper states it does. And they specificalls ask for clearly documented _code_. Somewhere else they say that if you submit code in an unusal language you have to name reviewers for that programming language. Sounds to me as if the reviewers are asked to actually look into the code.
Comment: @Gravitas: The better point to make regarding how #3 is inaccurate is that starting in R 3.0.0 the upper limit of information in R's workspace became the virtual-RAM the system could allocate (http://cran.r-project.org/src/base/NEWS.html).  Thus, with a large enough swap file most things are now possible.
Comment: @FrankHarrell The point is that it is hard for a user, much less the corporation employing the user, to know which are reliable. People release packages at different levels of development, and some people make serious errors.
Comment: @StasK, I think the issue here is what I had mentioned above. Certainly companies don't say, 'Oh, OK, that just won't get done then', they code it up themselves. SAS is notoriously poor as a programming language, as several commentators have pointed out on this page (I read your answer as having suggested that as well). So who guarantees the accuracy of that code?
Comment: @Peter: maybe reliability has a long term aspect as well. Does it do what I expect? Well, after decades of experience with one system (as a company) the flaws may be well known, so the expectations are met. This will not necessarily be the case with a new system, even if that meets its specifications far better... And about testing: it's up to us package programmers & users to get further into a culture of code review. But tools do exist already, e.g. the journal of statistical software explicitly says that the submitted code will undergo review.
Comment: I've had this conversation with people from a few large financial companies.  I think #2 is by far the most important factor for everyone I've talked to. Most of them  have specific policies prohibiting the use of open-source software.  I also think attitudes are slowly changing on that front.
Comment: On (3), SAS can be run in your database, so there's no need to move data around. If you develop a predictive model for things like targeted marketing, you don't need to worry about porting your model in some format like PMML every time you re-estimate the parameters. Also, JMP is a really nice program for less savvy users that may be uncomfortable with SAS.
Comment: Stata Corp is reasonably transparent about their approach: http://www.statajournal.com/article.html?article=pr0001 written by the president and the head of the development; http://www.stata.com/support/cert/. PeterFlom's point is the essense of why R is not being used more widely in high responsibility applications: there is little way to tell if the stuff that works does so correctly. gung, John Fox wrote sem package to teach a summer course, and until recently, it had functionality gaps. A good update came out a few months ago, although I have not yet fully checked it out.
Comment: @cbeleites Does JSS say the review will make sure the program does what it says, or only that it *runs* and appears to do something like what it says?
Comment: @BrianDiggs, that's a reasonable point, +1, although businesses are paying an arm and a leg to keep their SAS licenses up to date. I think the base starts at \$8k, but it can easily exceed \$20k per machine per year; at some point, you wonder if it would be worth paying programmers to rewrite that code in some freeware, be it R or Python.
Comment: @StasK, I'm hardly making that up; I've had several people tell me that. They believe that when they read in their data & run a regression, the results are correct, but that if you do this w/ R, there's no guarantee. I've had conversations w/ a number of people who believe this wholeheartedly & whose faith on this issue simply cannot be shaken. I'm referring to conversations / experiences I've *had*, not just heard about.
Comment: @gung: in your point 2 I'd distinguish between distrust of freeware and guaranteeing something. Sometimes even "a company" is not enough: I've met someone selling machinery under civil code (not sure about the correct term) saying he'd loose 90% of his customers the moment he'd set it up as a company because they know he's liable with his complete estate under civil law (which he wouldn't in a company setup). It's a matter of communicating that you are serious about what you are doing. Software sold by big companies often comes with statements of "without any warranty" as well...
Comment: @DimitriyV.Masterov: Revolution R is a commercial "enterprise" version of R that claims to allow R to run in-database. (I have not reviewed or audited this claim.) Revo R is not free ($1,000, I think), but its much cheaper than SAS.
Comment: @ArthurSmall: For the purpose of this question, I would put Revolution R into a different class. It seems more like S-Plus than ordinary R to me. It's definitely cheaper than SAS, which seems designed to extract all consumer surplus.
Comment: Point #3 has not been relevant for a long time: RevoScaleR allows arbitrary computations on datasets that are larger than system RAM.
Comment: There's also a liability issue in point 2. If I do analysis for a client and am wrong because of the software, I can sue SAS. With R, there's no one to sue.
Comment: #1 is a very large issues. I work in a SAS shop where many people have 20+ years of SAS and as a result all legacy code is written in SAS. Also, for a time the license issues around R caused hesitance to incorporating R into systems. That's not a problem anymore, but many people do not realize that.
Comment: Dear gung, a PO, has asked an interesting question [**HERE**](https://stats.stackexchange.com/questions/275895/are-cis-from-likelihood-function-cis-from-sampling-distribution) that has me think, do you think your could possibly answer that [***Question***](https://stats.stackexchange.com/questions/275895/are-cis-from-likelihood-function-cis-from-sampling-distribution)?
Answer: In addition to the good answers so far, I'd add the embarrassment factor. If you spend hundreds of thousands of dollars last year on SAS and SAS support, and you propose spending nothing for R, with extremely low support prices (Revolution, etc), someone up the chain's going to ask why. Was it a mistake to spend so much money last year when R existed last year? Or is it a mistake to drop professional software for something created by a group of volunteers?
Once the problem's framed in that manner, it's a lose-lose proposition, so perhaps better to not bring it up.
Comment: This is perhaps the most cynical answer on cross validated. +1
Comment: @probabilityislogic: Thanks! To be clear, this is more of a comment on poor higher-level management than on the people who use the software. I've worked in places where there really was the attitude (at higher levels), "Hmmm... you didn't spend all of the money we budgeted for you this year. Obviously you can get by on less money, so we're cutting your budget for next year and giving the extra to the department who overspent." Dilbert Rules.
Comment: "You did not spend the money..." -- that's exactly how the Soviet planning system used to work, from my firsthand knowledge.
Comment: Someone up the chain needs to be explained that for a fraction of the cost of a SAS license, you can install R Studio Server on an AWS Virtual Machine with 16 cores and 256 GB RAM - in the hands of 2 good R programmers, that's more powerful than anything SAS can do. Think how fast billion records can be fuzzy matched to each other ! Or for that matter even Open source PostgreSQL with Python + PERL will achieve at a fraction of a cost.
Comment: "Or is it a mistake to drop professional software for something created by a group of volunteers?"  This is a false dichotomy!
Comment: Hands down ! The best and most convincing answer ever.
Answer: On top of what gung has correctly identified here, the biggest issue in the corporate world is legacy. And when you have a good quality production code that is known to do the job, you don't change it. SAS was out there since 1970s, and at the time it was the only effective, by then-standards, scripting statistical language. The amount of production code accumulated since then in SAS in pharma and government is unimaginable, tens of thosands of human years. Rewriting this in R or Stata would take a few years, the resulting code will become more flexible, more efficient, more transparent, easier and cheaper to maintain, but nobody will pay for such refactoring. (My experience doing this is that my Stata code is generally about three times shorter; I once had a project converting SPSS code into Stata where I made it about 20 times shorter. For those of you who worked in maintaining your statistical packages... well, you know what that means.)
In a sense, this is a similar story with the academic publishers: they are riding a tide of the end users maintaining their subscriptions out of necessity; a university without subscription to Nature is not really a university. Free publishing via professional societies will make it cheaper, people prepare their submissions in LaTeX these days, so they are camera ready, and the same people will be providing the peer review, so there will be no quality setback on any of the dimensions. But... there's no brand name and the impact factor behind the online journals.
This sums it all up: http://scatter.wordpress.com/2011/06/28/stata-12/. Stata is preferred in economics and policy-related circles, and the more I learn SAS, the more I like Stata.
Comment: SAS has a horrific syntax that started with something similar to JCL (IBM's Job Control Language) for submitting punched-card batch jobs back in the day. It's remarkable that people are still using it, really.
Comment: +1 I particularly enjoyed the BlackBerry:iOS:Android:Nokia as SAS:Stata:R:SPSS analogy in the scatterplot post.
Comment: Wayne, if you have ever had given another thought about CARDS statement, you realize that SAS is the statistical software package to work with punchcards. Stata works with rectangular data sets. R works with objects. So depending on what kind of data format you have to deal with, one may be better than others.
Comment: One big point in the legacy is things like FDA approval or similar regulations. Industry I've spoken to won't touch anyhing(TM) after they got through that to be sure they don't have to go through the whole process again. And that is a big argument in terms of money.
Answer: I have worked as effectively a SAS programmer for the last seven years, next to me a co-worker has been programming SAS longer than I have been alive.  As noted here, there is a massive amount of inertia/legacy behind SAS; but SAS just like R is a way to a means, not the means itself.
SAS is extremely efficient at sequential data access, and database access through SQL is extremely well integrated.  PROC's are very well documented, but unfortunately not-entirely standardized with notation (PROC OPTMODEL and IML are two examples).   It is a bit clumsy when it comes to writing complicated code, and not as elegant for parallel code.  I have also found importing csv files to be a source of great misery at times and prefer to just dump it to R first then to a database.
Although SAS does have interfaces to shared objects and dll's you don't get nice access to any header files or anything like that, and code distribution also isn't available through happy packages.
There is however little concern about someone including some esoteric now-defunct or broken package in your code that you now need to maintain, and the quality of the code in SAS tends to be uniformly excellent (R core code is also excellent, and also freely available to anyone).
As mentioned before SAS is also extremely expensive, but it is a good tool that I go to when I know there is a canned procedure that works well for my needs.
R + SAS + mysql with a little bit of perl to glue to them together works amazingly :)
Comment: The remark about maintaining old packages goes just as well for a user written macro or an old proc that sas hasn't updated.
Comment: R has also very good SQL support gained recently via `dplyr` library - it literally translates R/dplyr syntax into SQL and calls the database, you can decide what operations to do on db server and what locally using the same syntax: https://cran.r-project.org/web/packages/dplyr/vignettes/databases.html
Answer: Nobody has suggested the reason it is preferred is plain idiocy. Here's two quotes I recently came across:

"Using open-source software such as R was out of the question – we
  couldn't guarantee a perfectly repeatable outcome"

and

"We would be unable to provide any support for this as it is open
  source software"

Two minutes with these people would show them how wrong they are.
Comment: @PaulHurleyuk: +1 The quote was "We have customers who build engines for aircraft. I am happy they are not using freeware when I get on a jet." by a SAS marketing director in [this New York Times article on R](http://www.nytimes.com/2009/01/07/technology/business-computing/07program.html/?pagewanted=all). The SAS representative [clarified her remarks in a later blog post](http://blogs.sas.com/content/sascom/2009/01/09/this-post-is-rated-r/).
Comment: In the two cases I quote, there could well be a rational decision, but the reasons given are clearly not those reasons. A rational reason might be "we already support SAS, and we can't afford to support two stats packages". But "We can't support this *because* it is open source" is a non-sequitur. The two parts may be true, but the conclusion does not follow. Its like saying "Elizabeth is the Queen because the sky is blue".
Comment: Two minutes with which people? Without references it's almost as if you just made those quotes up.
Comment: the second quote seems fine from a council IT department, they can't be expected to support all possible open source software that a customer might use, hence the blanket warning.  I think the worst anti open source quote I've heard was from SAS saying soemthing like 'would you trust a jumbo jet designed in open source, an engine might drop off'
Comment: @PaulHurleyuk: Equally the council can't be expected to support any *proprietary* software the customer might want to use. The open-ness is not the reason. If they'd said they couldn't support *anything* outside their supported set of software then fine.
Comment: http://www.sas.com/news/preleases/castle.html for the first, and the second was from a local council after a request from a student to have R on their council-supported laptop.
Comment: @Spacedman Back to the abacus in that council then...
Comment: "Can't provide support" is often a euphemism for "can't be bothered to install". I hereby promise that if I ever ask for support for something that my IT department warned me they "Can't provide support" for they can punch me in the face. As if anyone would go to a generic IT department for R support anyway. It would be like trying to buy a light aircraft from a supermarket.
Comment: I think many of you are showing anger toward the decisionmakers who use SAS instead of R.  The decisions are not totally irrational and do not necessarily mean that the decisionmaker thinks R or any other particular open source software is unreliable.
Comment: Well, in some recent costly accidents the reason was closed-source software written by boeing itself ...
Answer: So I use both R and SAS - admittedly in academia - but there are a couple reasons that I tend to head toward SAS at times:

Better documentation. R is getting better at this, but documentation, especially the official documentation, is often kind of terrible and opaque. Beyond that, SAS is supported by a massive infrastructure of books - the use R! series is helping this in R, but it's not quite there yet. I can turn to Paul Allison's Survival Analysis Using SAS, or Categorical Data Analysis Using SAS or the book I have on Monte Carlo methods using SAS and I have a book clearly written in a fairly consistent style for the language I'm using.
Inertia. This isn't just "companies are lazy" - inertia has value too. There's institutional knowledge. So-and-so has code that does that - and does it well.
Packages. Some packages in R are amazing. Some packages are not. You have to go find them, evaluate them, and even then there's some leap-of-faith issues in that the package is only as good as the guy writing it. It's hard to trust that. SAS has essentially the "full faith and credit of the SAS Institute" which has a pretty solid track record.
Single-source support. If SAS is broken, you call SAS. If R is broken you call....?
Comment: "If R is broken you call....?" Brian Ripley :-) (+1 for this well argued response)
Comment: ...SAS Institute provides paid support for SAS. Companies like Revolution Analytics and TIBCO (S+) provide paid support for R. If you want to compare paid support solutions for R and SAS, you should compare SAS Institute to Revolution Analytics and TIBCO, not R. The confusion, I believe, arises from the tight integration of the SAS language with the SAS Institute and the non-integration of the R language with R-related corporate support and education.
Comment: Regarding 4), I think there is a confounding of concepts. If you use a program and it breaks, you generally have two options. You can pay for support, or you can seek out freely available support (online community, literature, yourself). R and SAS can be compared as statistical programming languages. Both have freely available support, which can also be compared. R and SAS cannot be compared as paid support solutions...
Comment: @jthetzel I don't think its "confusion". SAS the language is tightly coupled with SAS the service. Any platform SAS works on has support from SAS. This is not true for R - support and the language are decoupled, there may be no help for you depending on platform (try talking to Revolution sometime while not using Windows or RHEL...), and they won't necessarily take responsibility for RandomPackage's errors, where as SAS will support PROC Arbitrary.
Comment: @probabilityislogic I think its beyond having to evaluate it to see if its appropriate for your analysis. Yes, both could be wrong, and both need to be evaluated. But I trust SAS's quality control team more than I trust me, on my own.
Comment: This is why I think your point 3 is more about the inertia behind SAS and its track record, as it really boils down to trusting the software provider.  "better the devil you know than the devil you don't" kind of thing.  Also, I'd add to your point #1 in that the error messages in SAS are way easier to decipher than the error messages in R.
Comment: Your point 3 is a bit biased, as you still need to investigate any new PROC to see if it is appropriate for your analysis.  I actually think point 3 this lies more as a "sub point" under the inertia/tradition/transition cost banner because people know how to evaluate PROCs in SAS - but its a different process in R.
Comment: @Fomite: This is like the Capitalism/Socialism debate: R is the free market solution, the marketplace is chaotic. SAS is pure communism: You get what the *politburo* (SAS Institute) offers. Socialism look nice in theory, but capitalism just works. (more or less, at least at times, and it autoupdates. It is at least better than Venezuela (or GULAG))
Answer: One issue does not seem to have been addressed explicitly: ass-covering. If you go with SAS and things blow up, the decision maker can always say that he bought state-of-the-art software, and how was he to know it would break? If he decided to go with R, this argument will be harder to make. Yes, this is related to the inertia argument already mentioned here.
A few decades ago, they used to say that "noboby ever got fired for buying IBM", which has been called the greatest marketing phrase ever.
Comment: Although, I'm not sure how R is any less state-of-the-art than SAS (and with regards to many procedures, I am under the impression that R is _more_ state-of-the-art than SAS). My guess is that a lot of SAS users don't know about that though...
Answer: The times they are a changing
As of 2015, actuaries under the age of about 35 prefer using R - the text books use both R and SAS code.  Older actuaries never learnt to use R and prefer SAS and do not use R.  The proportion of actuaries actually coding in SAS will decline.
If you search Google scholar for papers referring to SAS - then you will find a steady 550-ish publications per year for the last few years.  If you search for papers using R ("R Foundation for Statistical Computing"), there were 25,100 in 2014 and as of mid-July 2015 there are 16,700.  Plotting the rate - it's growing very fast!
SAS didn't help themselves for a few years by demanding large licence fees from universities - which they have since reversed - but it is now too late many universities have converted to teaching using R and not SAS.
New statistical techniques are published in papers in conjunction with an R package.  Some techniques that have been in base R for years have still not appeared in SAS.  You can now use R from inside SAS.
In summary, things are changing and changing fast.
Answer: As a user of both SAS and R, I would say the biggest reason we use SAS over R (when we do) is its ability for sequential processing.  We only need machines with no more than 4GB RAM to process 15 years worth of data.  I would need a much larger machine using stock R and I have not tried to migrate the SAS code to run with Revolution R.
Comment: +1, although it's worth noting that there are a few ways to work with larger-than-memory datasets in R ([bigmemory](http://cran.r-project.org/web/packages/bigmemory/index.html), [ff](http://cran.r-project.org/web/packages/ff/index.html), chunking data from a database, a wide range of distributed computing options).  But all of that takes setup; SAS will indeed just chug through whatever you throw at it, which is a real advantage.
Comment: As an update to my previous response, with the availability of many new tools to work with large data now (Arrow, Spark, DuckDB, etc.), there is just no reason to be using SAS anymore. R is MUCH easier to learn and use, is MUCH cheaper, is kept up to date with packages to do just about anything now, and integrates well with Quarto for documentation.
Answer: In the pharmaceutical industry SAS is used because it is what the FDA uses and likes.  There are some serious reasons though. Results are traceable and the output has a time stamp.  FDA statisticians can check what you get.  It is very good for database management and it is reliable software.  Of course many of the attributes of SAS can be argued to be present in other software packages including R and SAS is expensive.  Still I think anyone wanting to be an applied statistician working in industry will be best off to at least learn how to program in SAS.  Use R or STATA if you prefer but know SAS.  When you work for a company that wants you to use SAS they will pay for the licensing.
Comment: The FDA are quite vocal about _NOT_ endorsing or requiring any one software to be used.  It's historically true that most submission have used SAS, so the FDA have lots of SAS knowledge, but they have been very quick to embrace other systems, using R for quite a lot of recent work, especially around meta analysis.
Comment: Here's some additional information on the FDA's thinking with regards to R: http://blog.revolutionanalytics.com/2012/06/fda-r-ok.html
Comment: The R Foundation published a paper in 2008 discussing the [use of R in regulated clinical trials](http://www.r-project.org/doc/R-FDA.pdf). It should be a good reference for collaborators who are skeptical of using R.
Comment: i agree that there is a move to use R more in clinical research and that many believe that R can be made every bit as traceable as SAS.
Comment: @PaulHurleyuk  What the FDA will say publicly and how they act in practice are not necessarily the same.  Most pharma companies are primarily concerned with phase II and III clinical trials and they generally expect that they have to and will continue to need to use SAS for the analysis of those trials.
Comment: @Michael Would you mind providing an example of how SAS is more traceable than R (or how R would need to be "made" as traceable)?
Comment: I'd argue that R results are just as traceable and capable of being timestamped, and the link above suggests that at least some FDA personnel would be comfortable replicating results in R. No doubt that knowing SAS opens a lot of doors; I'm glad I know both SAS and R.
Comment: @MattParker I am not well-versed in that.  I am not claiming anything one way or the other. All I know is that I think it will be a long time before R has a prominent role as the analysis tool for FDA submissions.
Comment: Caveat: My answer here was given in 2012. It is now 2017.  I do not know about developments of other software in the intervening years.  I also do not know the current FDA position on software currently.  So keep that in mind when reviewing my answers and the answers of others.  I think the question and the various answers have historical interest and show how software products like R were catching up to SAS while being much less expensive or even free.
Answer: I think this quote from Anne H. Milley sums up the way a lot of people feel about R:

We have customers who build engines for aircraft. I am happy they are
  not using freeware when I get on a jet.

Unfortunately, I think this misconception (free==inferior) is common in the general public.
Answer: (slightly off topic): viewing it the other point round: some of the advantages R has in academia don't apply to industry.
E.g. in academia it is a clear advantage if you can tell the students to go and get the software and work at home. In industry, you're usually not supposed to take any data home with you...
Neither are you supposed to try out a few things(TM), download tons of packages (even if reputable & tested), use cutting-edge methods. Instead you're usually expected to stick to methods & code that have been used for years and where the behaviour is known for ages.
You wouldn't win much academic merits with that.
And of course, as has been mentioned: noone is going to risk redoing all kinds of regulatory approval for the sake of switching to R. From what I've seen that's less about R and more about the enormous costs + work for getting regulatory approval.
Comment: There is nothing that needs to be done to redo regulatory approval for the sake of switching to R.
Comment: @Frank: maybe we're thinking in different scenarios: I guess you're possibly thinking of a new trial (and there your're right) - I'm more thinking in terms of process analytics (chemical + statistical analysis) of ongoing production. AFAIK, you cannot just switch your data analysis there (but then, that's not SAS country) . But I may be wrong.
Comment: I'm not familiar with that world but I suspect that scientists have more freedom than they think.
Answer: Whilst its quite pessimistic, my answer would be that the kind of people who make sweeping decisions in corporations like 'we just use SAS' are also the kind of people who don't trust what they don't understand, and automatically think the value of something is directly proportional to the amount of money you spend on it.  This leads them to prefer paying for SAS rather than spend time investigating alternatives.
Answer: Why would a major drug company even want to convert to R from SAS? SAS costs millions but it is nothing to a drug company. However, converting all the stable reporting systems from SAS to R would cost 50-100 times more.
SAS has phenomenal support system: every time I needed help they were able to provide it within few hours.
And what exactly does R have that SAS does not:
1) better graphics...ok, it is a big one but graphics are not everything. besides R can     always be used an extra tool to create some cool graphs and SAS is not too bad when it comes to graphics
2) modern and more efficient programming language. Many SAS users are not programmers and don't care about using a cool language. They just want to be able to analyze the data.
I love R but it would be insane for a big company to convert to SAS. It could make sense for smaller firms though
Comment: Agree with you, @Max. Finally an answer coming from someone in the industry. It's EXPENSIVE to switch to R.
Comment: That is false.   The cost of programming support for SAS is much higher than that for R.  Companies hire hoards of SAS programmers to make up for the archaic language SAS uses.
Comment: I'm in industry and use both. R can perform data manipulations and, more importantly, analyses with *far* fewer lines, and hence can be developed much faster. I will say that some drug companies have thoroughly built out SAS systems for regulatory programming that have been successful. The point bears into consideration: why change (at this point)? If they were doing it from scratch, perhaps R instead.
Answer: There are several main advantages, in no particular order

SAS has a large installed base and a long track record

I'm purposefully avoiding use of pejorative terms like "legacy" or "habit"  Many companies have been using SAS for 30 or 40 years, and they have millions of lines of working code. In addition, there are all of the benefits of a stable code base with millions of user days in an area where small errors can be critical.   This is the same reason that Unix flavors are still popular even though Unix is over 40 years old and obsolete in some ways.  Finally, there is a large community of experienced SAS professionals who are used to solving business problems

SAS is well suited to heterogeneous, complex data and operating environments

Companies have lots of different data sources, based in different types of systems, as well as in many cases, multiple operating environments.  R has only very recently gotten some extremely basic capabilities to deal with more than can be kept in memory.  Compare this with SAS's ability to support native, optimized, in-database processing for terradata, to cite just one example.  In most real world situations, the hardest part of analytics is dealing with the data and operating environment. (need to run your Windows developed model scoring code on the mainframe?  With SAS, no problem.  With R, you are out of luck.)  R doesn't solve any of those problems.

The user doesn't have to worry about being "on their own"

A SAS user can be reasonably certain that every code module has been tested by qualified people. It is not necessary to devote time and effort to learning the provenance of the code, or independently validating it.  Furthermore, if issues of any kind are encountered, robust assistance (from something as basic as documentation to something as comprehensive as detailed exploring unexpected results or behavior of a sophisticated method) the user can pick up the phone and get help.

It's "good enough"

The language turns off some people because it is different than modern languages for general programming.  Having said that, the language is high level, powerful, expressive, and comprehensive.   In short, once you learn it, it gets the job done.   For companies, the elegance of the solution isn't much of a selling point.
Comment: Elegance maybe - but cost?  I think companies care about that!
Comment: R can run on anything from a mobile phone to a supercomputer at zero cost, and a mainframe too, also at zero cost.
Answer: Customer support.
I once had a chat with a friend working in a company specializing in installing servers, and he then explained to me why big companies always opt for Microsoft products rather than go open source. The advantage Microsoft has over its open source competitors is the customer support. If something goes wrong with the product, the company can call Microsoft, big companies even have personalized support for them. Not so with open source software.
I think that is the exact same reason SAS is getting precedence over R.
Comment: I think these comments are not correct.  In the server world, open source rules, and the Apache web server is the most popular web server.
Comment: revolution R (or other companies)?
Comment: Reminds me of companies that use a sharepoint and an open source wiki. Almost always the sharepoint is barren and only the wiki is updated.
Comment: I never said he was talking about servers. Rather about products like Microsoft Office. I only mentioned that he is **working** in the server world.
Answer: I once worked for a consulting company that gave SAS assistance to a large chip manufacturer in the Silicon Valley.  Our contact person at the company told us that he got an offer by another company to give them the exact same consulting, by using a different software which covers all areas covered by SAS and which would cost the company a fraction of what SAS was charging them (\$30,000 as opposed to \$1,000,000).
The contact person considered what to do and decided against informing his boss about the offer because he feared getting fired for using SAS in the first place and not considering cheaper alternatives.  Instead, he insisted that our consulting company give their company a big break in our consulting fee.  Our company agreed.
Comment: So your contact person couldn't make the argument that R is still relatively newcompared to SAS, and he wanted to wait to make sure R was established before using it?
Answer: What about Frontends? What is R's equivalent for the SAS Enterprise Guide, Web Report Studio or Enterprise Miner?
Edit:
These tools make it possible for a non-programming User to use a DATA WAREHOUSE, without knowledge about the underlying technology. They are not primarily tools for the use of SAS as such.
R GUI's are just IDE's for the R language/system, AFAIK. They cannot provide help for the non-technical user who wants to gain information & insight from the DWH.
Comment: Thank you for updating your answer, @Kurt. I think it will be more useful for future readers now. It is true that there are point & click, & data warehouse offerings for SAS that are more comprehensive, & ready-to-go out of the box than R. That is a reasonable point to raise. +1
Comment: It IS an answer. What makes SAS so valuable to customers (like us) is the ease of use for people who don't have to write a single line of code.
Comment: @Kurt, gung didn't want to mean that this is not an answer, but rather that your answer does not fit to this site (and especially for the present question, actually)
Comment: Well, I have worked with RStudio. Compared to SAS Enterprise Guide, its still has a very long way to go until it reaches the ease-of-use for a newbie user. Add the fact that R is missing an equivalent to the Metadata Server.
And I completely miss an out-of-the-box equivalent for WRS (maybe I'm blind :)).
The beauty of a language and the productivity you can achieve means next to nothing for companies where 90% of the data warehouse "customers" couldn't write "Hello World" in any programming environment. That's what I wanted to point out, and that's where a lot of work is left to do.
Comment: Agree with gung, and I removed my downvote. It's a valid point, I've been hoping for a better R GUI - something to complete with JMP, which is what my undergrad school taught (uselessly for us physical scientists, who all use R or some other programming language). RKward is getting there, and was quite good when I last used it about 2 years ago. It's nice because it shows the code, and allows you to enter your own, so it's a good stepping stone to full R, but it's definitely not as polished as JMP.
Comment: There are tonnes of GUIs for R, see http://stats.stackexchange.com/questions/5292/good-gui-for-r-suitable-for-a-beginner-wanting-to-learn-programming-in-r
Comment: While this answer was correct, in 2019 Rstudio has absolutely transcended all available front ends for SAS. So much so, SAS has developed "SAS studio" which is a lack luster counterpart.
Answer: I don't think application security has been mentioned. This question was raised in Stack Overflow but dropped since it was off topic.
I collaborate with the the Swedish National Board of Health and Welfare that use SAS. When I talked to their statisticians (that like R) they claim that their IT-folks prefer SAS since they don't trust the packages downloaded in R. My wife also works in SAS and her institution often claims the same issue...
I would love to see some comments on this issue. I've done a quick search but haven't found any good references...
Comment: What is the alternative to downloading a package that provides new capabilities (as most R packages do)?  Is it to home grow those capabilities?  Is that more reliable?
Comment: @FrankHarrell I agree, but I think this may be an easy area for the R developers to target and improve. A simple solution could be different levels of security for packages - if a package has a system call or connects on its own to the Internet the package should have a higher clearance. This could allow installations with only low-level clearance in those institutions/companies where a data leakage is of major concern. I as a user could then also do an extra check when I choose to install a high clearance package. (Btw, when is your book (RMS ver 2) scheduled?)
Comment: I'm hoping that the 2nd edition of RMS will be available in just over a year.
Answer: The reason I understood to be the most convincing was that SAS has an extensive library of vertical business specific modules that people in these verticals all use, so it is somewhat of a lock-in.
But also that SAS has addressed the needs of these vertical segments in business and optimized around their needs - optimized in the sense of "user doesn't have to do a lot of extra work to get the results".  I am not a SAS user, so this is not meant as a biased defense of the SAS business strategy.
Answer: Being the big commercial product that SAS is, there's a strong and coordinated effort by payed salespersons to promote it. I don't think that efforts to promote the usage of R can match these.
Comment: Yes, people have to some extent discover R on their on.  But much of the issue comes down to inertia of learning a new language.  New languages are always coming out that have advantages over older languages yet users cling to the old languages (witness COBOL).  Programming in SAS is hugely inefficient, requiring perhaps double the number of programmers to do the same job as R, but SAS experts are happy to hum along on their merry way and companies are afraid of the kind of disruption that would save them millions of dollars in salaries.
Answer: I look at Open Source or licenced software like this, be it SAS or anything else. My IT department is there to provide a service to our business. The company earns no money from IT, only from the business IT supports. The business has annual revenues of \$16 Billion. IT costs around \$200 million a year. If money was the issue I would cut costs, but if I save 10% (\$20 million) of my budget, will the business notice? Will they just reduce my budget next year? If the IT fails the business loses revenue, how much will vary on the nature of the failure. Parts of the business may no longer earn revenue. If a product like SAS fails, I can sue under a contract. If an OSS product fails, I cannot. I will not recover my \$16 Billion, but I may get some back, and realistically with SAS, you are unlikely to lose the lot. The difference in price versus cost has to justify any additional perceived risk to the business. Sometimes it is cheaper to stick with SAS than to retrain. Sometimes there are higher priority issues, so companies stay with SAS. Some companies do not need the full functionality in which case alternatives are viable. Some do not need the support and again the alternatives are viable. If you meet the business requirements then either options are valid, if you want to provide support for a business you need to look at the total cost of ownership over 5-10 years, the ability to recruit experts in the tools, stability in the product so you don't have to rewrite everything with each new release, the training courses available to skill up, the size of the potential skills available in your region... Often the biggest problems with OSS come about through the poor architecture of the products, look at Linux when 64 bit processors came out, look today at MySQL was recently ported but without support for secondary indexes which is coming later...
Comment: Having used SAS for 23 years and S-Plus/R for 22 years I can say that a highly experienced SAS programmer can be highly productive, but that an experienced R programmer can be easily three times as productive.
Comment: I don't follow your reasoning.  The amount of money wasted paying programmers to program in an archaic language (SAS) vs. modern free languages is stunning.
Comment: @Frank - I have to disagree with your characterization.  A competent SAS programmer can be highly productive in SAS, and competent SAS programmers are widely available.  I grant you that R is structured more like a modern language, and so might be easier to learn for programmer who knows, say, Java.  In my experience at many companies, developer productivity using SAS is rarely a material issue.
Comment: "I can sue under contract"  haha - incorrect code written by employees is far more likely to cause problems than something SAS or R does "on its own"
Answer: Some reasons that I haven't seen mentioned:

Better documentation.  SAS documentation is verbose, R documentation is terse. Many companies may prefer verbose documentation.
Better error messages. R's error messages often seem designed to prove that the person writing the message is smarter than the person reading it.
Tech support. SAS has some of the best tech support I've run into anywhere, provided by SAS. You can get help with R, but that help is scattered over different places and isn't always available. The people on the various sites that provide help with R are volunteers - and volunteers aren't obligated to help.  The people at SAS tech support are paid to do what they do - and they do it well. Not only do they do it well, they do it politely a trait that is often not present in all R communities (my favorite? "I got help by typing 'help', why don't you try typing 'help'?")
Ease of coordination with Word and Excel. Yes, I know you can get R to do this, but it's easier with SAS (on the other hand, R works better with $\LaTeX$ but a lot more  companies use Word).
Comment: I am sure there are companies that sell tech support for R. But how good that is I have no experience!
Answer: I think the legacy angle can be a big one for the following reason. An organisation hires a person, call them person X. They are a computing guru/wizard/etc. They build awesome SAS programs/tools/etc. They are so good that other people in the organisation don't feel like they need to understand how the programs work. They make it so easy to just push a button, and everything just works (the magic black boxes).
Person X leaves the organisation. Unfortunately, the knowledge that person X has leaves the organisation (documentation and knowledge management was not prioritised, working programs was instead).
They are replaced by person Y. Person Y is great with R but has no idea about SAS, and hence has no idea about how the SAS programs actually work. There is a huge learning curve to even figure out what needs to be translated into R.
For example, person Y can not tell if a data transformation has been done to enable a proc to be called, or for merging with other data, etc.
The transformations needed are probably different in R, because the functions are different, and the defaults are different (e.g. treatment of categorical variables in proc glm vs the lm())
So, you are now faced with a unequal cost trade off. Say the cost of re-writing / translating from SAS to R is $C_T$. We then need the (small?) efficiency gain from moving to R (I say small based on my experience with optimising SAS code and optimising R code for logistic regression predictions). This also needs to be compared to the license costs for SAS. It is likely that $C_T$ is significantly higher than a single year license for SAS. I expect that SAS would be doing some analysis of this trade off, and letting this influence how it sets the licence fee (well, I would if I worked at SAS).
Also notice how SAS plotting procedures are way better than a decade or so ago (eg proc sgplot vs proc plot). coincidence that R did good plotting first? I think not! This effectively reduces the efficiency from switching because plotting is not so different anymore - R is still better, but not by enough to switch...
Answer: For industrial statistics, there are quality assurance people who (usually) have no programming, statistics, or science background and who audit statisticians, programmers, and scientists. They want to know, "How do you know that what you're doing is right?" and "If it's wrong, how can we blame somebody and how will they pay for it?".
The GNU/GPL Copyleft license comes with canned text that says, "R is free software and COMES WITH ABSOLUTELY NO WARRANTY" in all-caps text exactly as I have written. This is offputting. When a quality person reads this text, they basically discredit R outright. I mean, if a product is good, it's worth adding a warranty right? Such has commercial products led us to believe. In fact, it was ultimately the FDA who said they would accept regulatory submissions in R that reflected a seachange in the software industry. (Note this statement comes after the original posting date of the question.)
For someone who knows nothing about computers, the imagined scenarios of security, irreproducibility, and grave scientific errors are unbounded as a result of this ABSOLUTELY LACK OF WARRANTY.
 We all agree mistakes can have catastrophic costs. For your SAS license, SAS has experts who can explain their software to auditors, and in the impossible scenario that SAS actually causes such an issue, they can be accountable for fines and punishments (they also have enough money for lawyers to ensure they'd be exonerated completely in such a case). The burden and cost of having an analyst/programmer present this case for R basically amounts to a SAS license. Not that programming in SAS completely exonerates you from the crushing burden of quality compliance!
So basically, I would say litigiousness has played a prominent role in necessitating a costly license software.


What is acceptable error in prediction models?

Question: I have developed a model for construction waste reduction, but I'm not sure how to validate it to serve the purpose. I have two sets of data: measured waste % from sites and predicted values obtained from model constructed. How do I tell that the model constructed is good for prediction purposes? The data is linearly related.
Comment: This depends entirely on *your* objectives: why are you predicting? What are you going to do with the predictions later on? What's the cost of being wrong? How precise do you *need* the predictions to be to make use of them at all? ...
Comment: Thanks Marc, the purpose is to be able to predict future waste generation on similar projects as one studied and materials observes.the precision is what im asking, what should be acceptable difference between actual and predicted values?thanks.Lawrence
Answer: @Marc is right. The acceptable precision (and total error) depends on your application - it doesn't have anything to do with the modeling.

If this is an industrial or close-to-industry project these needs should be in the specifications.
As an alternative, look into the relevant literature about your application.


How to simplify $-\sqrt {16x^2}$ when $x < 0$?

Question: What is $-\sqrt {16x^2}$ when $x < 0$?
Thanks
Comment: What do you get when $x = -1$?
Comment: What are your thoughts?
Comment: $\sqrt {16x^2} = \sqrt {(4x)^2} = |4x|$.
Answer: In any case, the expression $\sqrt {x^2}$ equals $|x|$. Then, we got that:
$$-\sqrt{16x^2}=-\sqrt{16}\cdot\sqrt{x^2}=-4\cdot|x|.$$
Now, since $|x|=-x$ for all $x<0$, we conclude that:
$$x<0\implies -\sqrt{16x^2}=\boxed{4x}$$


Gradient of softmax with cross entropy loss

Question: I'm working on implementing a simple deep model which uses cross-entropy loss, while using softmax to generate predictions.
More specifically, I am interested in obtaining the gradient of $$CE(softmax(\vec \beta), \vec x)$$ with $\beta = A^T \vec y$, such that $\beta_i = \vec a_i^T \vec y$ with respect to $\vec y$
By the chain rule, I get
$$\frac{dCE}{dy} = \frac{dCE}{d softmax(\beta)} \frac{dsoftmax(\beta)}{d\beta} \odot \frac{d\beta}{d y}$$
Here, the elementwise product comes from the derivative of an elementwise function (chain rule applied to elementwise functions).
I calculate that
$$\frac{dCE}{d \beta} = softmax(\beta) - \vec x$$
So far this makes sense (and I have managed to verify the above using various sources online). However, when I try to calculate $d\beta/dy$, I get $A^T$, which doesn't make sense, as the elementwise product isn't defined for matrices of differing dimensions (AKA my vector $softmax(\beta) - \vec x$ and matrix $A^T$)
Can anyone shed some light onto where I am going wrong?
Comment: it should be something like $$\sum_i\frac{dCE}{d\beta_i}\frac{d\beta_i}{dy}$$ but i couldn't tell where goes wrong..
Comment: So I managed to work out the partial in terms of an individual element... $\frac{dJ}{d(y)_i} = (a_k)_i - \frac{\sum_j (a_j)_i * \exp(a_j^T y)}{\sum_l \exp(a_l^T y)} = (a_k)_i - \sum_j (a_j)_i * \frac{\exp(a_j^T y)}{\sum_l \exp(a_l^T y)}$ (note, one assumption I am making is that my desired cross-entropy vector is one-hot with the kth element being the one element). I am unsure how to vectorize this notation. Any thoughts?
Answer: $y$ and $\beta$ are vectors, hence writing $M=\frac{d\beta}{dy}$ implies the result is a matrix $M$ with components $M_{ij}=\frac{d\beta_i}{dy_j}$, which happens to be equal to $A^T$. See Matrix Calculus for more identities.
Comment: Sure, but then how does one make sense of the element-wise product? I am definitely understanding that the $d\beta/dy$ should result in a matrix, but I am confused as to how to understand $(softmax(\beta) - \vec x) \odot M$. Did I make a mistake somewhere else?


in-addr.arpa zone delegation in Bind 9 and Samba 4 as an AD DC with DDNS

Question: Environment and goals
In my testing KVM lab I have a virtual network 172.16.50/24, in this network I have got 2 Centos 7 VMs running Bind 9 and ISC DHCP servers:

Мастер DNS : controller.wsvirt.home (172.16.50.2)
Slave DNS: controller2.wsvirt.home (172.16.50.3)

All clients in the network are Linux VMs and all of the them get network configuration from the DHCP server. This server dynamically updates DNS zones.
Bind 9 is an authoritative server for wsvirt.home zone.
In the lab environment I test a scenario which I have to implement in our business office network. In the business environment I should create an AD domain to serve Windows clients and for this purpose we have decided to utilize Samba 4 as a DC. I have built a Samba server for Centos 7 with Heimdal Kerberos support from the sources.
For the AD I allocated subnetwork 172.16.50.192/26 and assigned ad.wsvirt.home domain.
AD DC is a Centos 7 VM running Samba 4, Bind 9 and ISC DHCP servers. Samba makes use of BIND_DLZ as a DNS backend. AD controller has addc1.ad.wsvirt.home domain name and IP 172.16.50.193.
All Windows AD clients get IP from the DHCP server running on the AD DC which dynamically updates Bind DLZ zones.
In the real working physical environment all client PCs from the both networks should be connected to one broadcast domain.
To satisfy the requirements I delegated authority for the forward ad.wsvirt.home and reverse 172.16.50.192/26 DNS zones from the Bind on the controller.wsvirt.home server to the AD controller addc1.ad.wsvirt.home accordingly to RFC 2317.

# Problem #
Everything works perfectly except one thing. When I test revers lookup for delegated reverse zone over AD DC then result looks OK, thus Windows AD client could resolve all reverse domain name in both domains. :
$ dig -x 172.16.50.193 @addc1.ad.wsvirt.home

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> -x 172.16.50.193 @addc1.ad.wsvirt.home
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43507
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;18.104.22.168.in-addr.arpa.    IN      PTR

;; ANSWER SECTION:
22.214.171.124.in-addr.arpa. 86400 IN    CNAME   184.108.40.206.ddns.
184.108.40.206.ddns.     900     IN      PTR     addc1.ad.wsvirt.home.

;; Query time: 7 msec
;; SERVER: 172.16.50.193#53(172.16.50.193)
;; WHEN: Mon Mar 30 21:05:12 IDT 2020
;; MSG SIZE  rcvd: 121

But when I route my requests to the DNS server controller.wsvirt.home it does not resolve any reverse name from the ad.wsvirt.home domain, consequently the Linux clients could not lookup any reverse name as well:
$ dig -x 172.16.50.193 @controller.wsvirt.home

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> -x 172.16.50.193 @controller.wsvirt.home
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 48825
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;22.214.171.124.in-addr.arpa.    IN      PTR

;; ANSWER SECTION:
184.108.40.206.in-addr.arpa. 86400 IN    CNAME   220.127.116.11.ddns.

;; AUTHORITY SECTION:
.                       8133    IN      SOA     a.root-servers.net. nstld.verisign-grs.com. 2020033001 1800 900 604800 86400

;; Query time: 0 msec
;; SERVER: 172.16.50.2#53(172.16.50.2)
;; WHEN: Mon Mar 30 21:49:41 IDT 2020
;; MSG SIZE  rcvd: 162

I need Linux clients from the wsvirt.home domain to be able to resolve reverse domain names in the ad.wsvirt.home domain. Is it possible at all?

Configurations
To be more precise I put here my configuration files for both servers
Server controller.wsvirt.home
/etc/named.conf
acl local { 172.16.50.0/24; 127.0.0.1; };

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
include "/etc/rndc.key";

server 172.16.50.3 {
        keys { "rndc-key"; };
};

...

options {
        listen-on port 53 { local; };
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        recursing-file  "/var/named/data/named.recursing";
        secroots-file   "/var/named/data/named.secroots";
        allow-query     { local; };
        allow-transfer { none; };
        notify no;
        forwarders { 18.104.22.168; 22.214.171.124; };
        forward only;
        recursion yes;
        dnssec-enable yes;
        dnssec-validation yes;
        bindkeys-file "/etc/named.iscdlv.key";
        managed-keys-directory "/var/named/dynamic";
        pid-file "/run/named/named.pid";
        session-keyfile "/run/named/session.key";
};

zone "." IN {
        type hint;
        file "named.ca";
};

zone "wsvirt.home" IN {
        type master;
        file "wsvirt.home.db";
        allow-update { key "rndc-key"; };
        allow-transfer { key "rndc-key"; };
        notify yes;
        forwarders {};
};

zone "50.16.172.in-addr.arpa" IN {
        type master;
        file "50.16.172.db";
        allow-update { key "rndc-key"; };
        allow-transfer { key "rndc-key"; };
        notify yes;
};

/var/named/50.16.172.db
$ORIGIN .
$TTL 86400      ; 1 day
50.16.172.in-addr.arpa  IN SOA  controller.wsvirt.home. root.wsvirt.home. (
                                153        ; serial
                                3600       ; refresh (1 hour)
                                1800       ; retry (30 minutes)
                                604800     ; expire (1 week)
                                86400      ; minimum (1 day)
                                )
                        NS      controller.wsvirt.home.
                        NS      controller2.wsvirt.home.
$ORIGIN 50.16.172.in-addr.arpa.
2                       PTR     controller.wsvirt.home.
$TTL 86400      ; 1 day
3                       PTR     controller2.wsvirt.home.
...
;
50.16.172.ddns.         IN      NS      addc1.ad.wsvirt.home.
$GENERATE 193-254 $     IN      CNAME   $.50.16.172.ddns.

/etc/dhcp/dhcpd.conf
include "/etc/rndc.key";

default-lease-time 600;
max-lease-time 7200;
authoritative;
ddns-update-style interim;

class "windows" {
        match if substring (option vendor-class-identifier, 0, 8) = "MSFT 5.0";
}

subnet 172.16.50.0 netmask 255.255.255.0 {
        log (info, concat("Vendor Class ID (60): ", option vendor-class-identifier));
        log (info, concat("DHCP Client ID (61): ", option dhcp-client-identifier));
        log (info, concat("User Class ID (77): ", option user-class));
        option domain-name-servers 172.16.50.2, 172.16.50.3;
        option ntp-servers 172.16.50.2;
        option routers 172.16.50.1;
        option broadcast-address 172.16.50.255;
        default-lease-time 600;
        max-lease-time 7200;
        option ip-forwarding off;
        ignore client-updates;
        option domain-name "wsvirt.home";
        option domain-search "wsvirt.home";
        option netbios-scope "";
        option netbios-node-type 8;
        option netbios-name-servers 172.16.50.2;
        option netbios-dd-server 172.16.50.2;
        ddns-updates on;
        ddns-domainname "wsvirt.home.";
        ddns-rev-domainname "in-addr.arpa.";

        pool {
                range 172.16.50.21 172.16.50.190;
                deny members of "windows";
        }

        zone wsvirt.home {
                primary 172.16.50.2;
                key "rndc-key";
        }

        zone 50.16.172.in-addr.arpa {
                primary 172.16.50.2;
                key "rndc-key";
        }
}

AD DC addc1.ad.wsvirt.home
/etc/named.conf
options {
    listen-on port 53 { any; };
    listen-on-v6 port 53 { ::1; };
    directory   "/var/named";
    dump-file   "/var/named/data/cache_dump.db";
    statistics-file "/var/named/data/named_stats.txt";
    memstatistics-file "/var/named/data/named_mem_stats.txt";
    recursing-file  "/var/named/data/named.recursing";
    secroots-file   "/var/named/data/named.secroots";
    allow-query     { any; };
    forwarders  { 172.16.50.2; 172.16.50.3; };
    forward only;
    recursion yes;
    dnssec-enable no;
    dnssec-validation no;
    bindkeys-file "/etc/named.root.key";
    managed-keys-directory "/var/named/dynamic";
    pid-file "/run/named/named.pid";
    session-keyfile "/run/named/session.key";
    tkey-gssapi-keytab "/var/lib/samba/private/dns.keytab";
    minimal-responses yes;
};

...

zone "." IN {
    type hint;
    file "named.ca";
};

include "/etc/rndc.key";
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
include "/var/lib/samba/bind-dns/named.conf";

/etc/dhcp/dhcpd.conf
include "/etc/rndc.key";

default-lease-time 600;
max-lease-time 7200;
min-secs 5;
authoritative;
ddns-update-style none;

class "others" {
    match if substring (option vendor-class-identifier, 0, 8) != "MSFT 5.0";
}

subnet 172.16.50.192 netmask 255.255.255.192 {
    log (info, concat("Vendor Class ID (60): ", option vendor-class-identifier));
    log (info, concat("DHCP Client ID (61): ", option dhcp-client-identifier));
    log (info, concat("User Class ID (77): ", option user-class));
    option routers 172.16.50.1;
    option broadcast-address 172.16.50.255;
    default-lease-time 600;
    max-lease-time 7200;
    option ip-forwarding off;
    ignore client-updates;
    option ntp-servers 172.16.50.193;
    option domain-name-servers 172.16.50.193;
    option domain-name "ad.wsvirt.home";
    option domain-search "ad.wsvirt.home";
    option netbios-name-servers 172.16.50.193;
    option netbios-dd-server 172.16.50.193;
    option netbios-scope "";
    option netbios-node-type 8;
    ddns-rev-domainname "ddns";

    pool {
        range 172.16.50.210 172.16.50.254;
        deny members of "others";
    }
}

on commit {
    set noname = concat("dhcp-", binary-to-ascii(10, 8, "-", leased-address));
    set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
    set ClientDHCID = concat (
    suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), ":",
    suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), ":",
    suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,3,1))),2), ":",
    suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1))),2), ":",
    suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), ":",
    suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,6,1))),2)
    );
    set ClientName = pick-first-value(option host-name, config-option-host-name, client-name, noname);
    log(concat("Commit: IP: ", ClientIP, " DHCID: ", ClientDHCID, " Name: ", ClientName));
    execute("/usr/local/sbin/dhcp-dyndns.sh", "add", ClientIP, ClientDHCID, ClientName);
}

on release {
    set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
    set ClientDHCID = concat (
    suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), ":",
    suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), ":",
    suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,3,1))),2), ":",
    suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1))),2), ":",
    suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), ":",
    suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,6,1))),2)
    );
    log(concat("Release: IP: ", ClientIP));
    execute("/usr/local/sbin/dhcp-dyndns.sh", "delete", ClientIP, ClientDHCID);
}

on expiry {
    set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
    log(concat("Expired: IP: ", ClientIP));
    execute("/usr/local/sbin/dhcp-dyndns.sh", "delete", ClientIP, "", "0");
}

A DLZ revers zone 50.16.172.ddns on the AD DC
$ samba-tool dns query localhost 50.16.172.ddns @ ALL
Password for [email@example.com]:
  Name=, Records=2, Children=0
    SOA: serial=3, refresh=900, retry=600, expire=86400, minttl=3600, ns=addc1.ad.wsvirt.home., email=hostmaster.ad.wsvirt.home. (flags=600000f0, serial=3, ttl=3600)
    NS: addc1.ad.wsvirt.home. (flags=600000f0, serial=1, ttl=3600)
  Name=193, Records=1, Children=0
    PTR: addc1.ad.wsvirt.home (flags=f0, serial=3, ttl=900)
  Name=230, Records=1, Children=0
    PTR: winxp-1.ad.wsvirt.home (flags=f0, serial=3, ttl=3600)

Answer: It's normal not to get the PTR on the same answer, as the controller.wsvirt.home. isn't an authoritative name server for both zones. The flags: aa states that this is an authoritative answer, but that wouldn't be true for 126.96.36.199.ddns. IN PTR. Therefore, it can't be sent on this authoritative answer.
This is not really a problem, because that only causes another query for 126.96.36.199.ddns. IN PTR, which could then be answered recursively. Clients should be aware of doing this automatically in case of a CNAME answer.
Regarding that, there's another problem, as only addc1.ad.wsvirt.home. has zone 50.16.172.ddns.; you would get an NXDOMAIN answer on:
dig 22.214.171.124.ddns. PTR @controller.wsvirt.home

The controller.wsvirt.home. is configured as recursive (recursion yes;), but it's not aware that these addresses could be found on addc1.ad.wsvirt.home.. Therefore, it tries to resolve them as everything else: from the forwarders { 184.108.40.206; 184.108.40.206; };... and fails.
You could add the addc1.ad.wsvirt.home. as a forwarder for 50.16.172.ddns. on the controller.wsvirt.home.:
zone "50.16.172.ddns." {
    type forward;
    forwarders { 172.16.50.193; };
};

Finally, the zone for $ORIGIN 50.16.172.in-addr.arpa. could only delegate control for its own subdomains – not for a completely unrelated 50.16.172.ddns..
If you really still want to send the PTR on the same response, you need to make this domain authoritative for 50.16.172.ddns. by adding a slave zone (instead of a forward zone), e.g.
zone "50.16.172.ddns." {
    type slave;
    file "50.16.172.ddns.db";
    masters { 172.16.50.193; };
};

The primary server (addc1.ad.wsvirt.home.) needs to be aware of this and allow zone transfers from controller.wsvirt.home. (and controller2.wsvirt.home, if it should act similarly):
options {
    . . .
    allow-transfer { 172.16.50.2; 172.16.50.3; };
}

Comment: I think now I understood your concern: I only saw a real problem in your configuration, not the one you were explaining you are having. Now my answer should have the full picture.
Comment: Thanks for the reply bu it does not help. I have played around with forwarding and got the same result when digging.
Comment: Additionally I have to mention that RFC 2317 does nor require to do anything with forwarding it rather suggests to make an alias to delegated revers zone therefore on the controller.wsvirt.home I have in the reverse zone file /var/named/50.16.172.db the following lines: 50.16.172.ddns.         IN      NS      addc1.ad.wsvirt.home.
$GENERATE 193-254 $     IN      CNAME   $.50.16.172.ddns.
Comment: But `50.16.172.ddns.` is not a subdomain of `50.16.172.in-addr.arpa.`, so it can't delegate control of it to other name server...
Comment: Anyway the forwarding doesn't help.
Comment: Thanks for your clarification I hope I understood your advise correctly and did as you suggest, the result I have described below in my new answer.
Answer: If you are going to use MY script, please use it correctly ;-)
Run Bind9 and isc-dhcp on the DC, no where else.
See here:
https://wiki.samba.org/index.php/Setting_up_a_BIND_DNS_Server
https://wiki.samba.org/index.php/Configure_DHCP_to_update_DNS_records_with_BIND9
One of your main problems is that you are trying to store the reverse zone in a 'flatfile' and bind9_dlz does not work with flatfiles.
Comment: Because things like :

zone "50.16.172.ddns." {
    type slave;
    file "slaves/50.16.172.ddns.db";
    masters { 172.16.50.193; };
};

Are flatfiles and do not work with bind9_dlz.

Follow the samba wiki and it will work, well it has for me for the last 8 years.
Comment: I don't use such lines at all. If you look closely at the posts above you could see that Esa Jokinenn advises to put these lines in the Bind's config, not me. I only tried it  once unsuccessfully following the advise. By the way I have decided the issue, look my post below.
Comment: First of all I want to thank you for your grate script, it works good and I used mentioned guides as a major reference. Now I have to admit that Samba, Bind and DHCP servers run on the same system. And finally, would you tell me please why do you think that I store my reverse zone's RRs  in a flat file?
Answer: Accordingly to the Esa Jokinen's suggestion I did the following:
On the controller.wsvirt.home in the /etc/named.conf I created a zone section for 50.16.172.ddns.
zone "50.16.172.ddns." {
    type slave;
    file "slaves/50.16.172.ddns.db";
    masters { 172.16.50.193; };
};

In the zone file /var/named/50.16.172.db I commented out the lines delegating the 50.16.172.ddns zone:
;50.16.172.ddns.                IN      NS      addc1.ad.wsvirt.home.
;$GENERATE 193-254 $    IN      CNAME   $.50.16.172.ddns.

On the addc1.ad.wsvirt.home. in the /etc/named.conf:
options {
    . . .
    allow-transfer { 172.16.50.2; 172.16.50.3; };
}

As a result I have an authority for the zone 50.16.172.ddns but revers names got unresolved at all:
dig -x 172.16.50.193 @addc1.ad.wsvirt.home

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> -x 172.16.50.193 @addc1.ad.wsvirt.home
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 30147
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;184.108.40.206.in-addr.arpa.    IN      PTR

;; AUTHORITY SECTION:
50.16.172.in-addr.arpa. 10800   IN      SOA     controller.wsvirt.home. root.wsvirt.home. 154 3600 1800 604800 86400

;; Query time: 5 msec
;; SERVER: 172.16.50.193#53(172.16.50.193)
;; WHEN: Wed Apr 01 17:20:44 IDT 2020
;; MSG SIZE  rcvd: 118

$ dig -x 172.16.50.193

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> -x 172.16.50.193
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 62725
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;22.214.171.124.in-addr.arpa.    IN      PTR

;; AUTHORITY SECTION:
50.16.172.in-addr.arpa. 86400   IN      SOA     controller.wsvirt.home. root.wsvirt.home. 154 3600 1800 604800 86400

;; Query time: 0 msec
;; SERVER: 172.16.50.2#53(172.16.50.2)
;; WHEN: Wed Apr 01 17:20:56 IDT 2020
;; MSG SIZE  rcvd: 118

Answer: Finally I have discovered a root of the problem. The point is that Bind 9 strips away DNSSEC signatures, when it works as a forwarder. I knew it, so in the named.conf at the server addc1.ad.wsvirt.home I set the following options as a workaround:
dnssec-enable no;
dnssec-validation no;

But I forgot to do the same at the controller.wsvirt.home, now I have fixed my oversight and everything works good. And obviously the zone section for the 50.16.172.ddns must be in the Bind's config file at the addc1.ad.wsvirt.home server:
zone "50.16.172.ddns." {
    type forward;
    forwarders { 172.16.50.193; };
};


Lock dependencies by secure checksum in Maven

Question: When I distribute a source project with a POM I can define dependencies with version strings. The build will download those dependencies if they are not in the local repository, it will even verify the checksums of those downloaded files with the metadata from the same repository (-C).
However the build will download those dependencies from a number of public repositories (and proxies) and my users are at the mercy of those public services if they will return unmodified files.
I would like to have a way to record the checksums of all my build dependencies and ship them together with the POM (so I am sure the files are unaltered but I dont need to ship a copy of my local repository to builders).
Is there a Maven way to do this? Similiar to that, is there a easy way to archive my dependencies (copy of the local repository with all used artifacts and metadata files) so I can repeat my build even when the central repositories fail or ship them to offline customers?
(Both without the need for an repository proxy if possible. I know I can build something to do that, I just wonder if there is a infrastructure in maven for that already. Maybe shipping a local repository which does only contain the metadata files or similiar?)
NB: I am not looking for createChecksum on the generated artifacts, but on locking the checksums of the used dependencies. I found a maven-create-checksums plugin, but no corresponding verifyer.
Comment: Sonatype requires a GPG signature on every artifact uploaded into Maven Central. Maven does not check this signature, because checking it is a selling feature of the commercial flavor of their Nexus repository manager. The connection between your commercial Nexus instance and your build machine is assumed safe (and, admittedly, easy to secure).
Comment: I know it's not helpful, that's why I didn't post it as an answer :-/. It does explain why the GPG checksum situation is the way it is.
Comment: Thanks @Barend, but this does not help me if I want to distribute to a wider audience (who probably not even have own repository servers)
Comment: Thanks Barend, I guess I should have a look into writing plugins :)
Comment: The checksum check is also in Nexus OSS btw.
Comment: How is the trust relation to the expected checksum (or gpg key) established? When I created my sonatype OSS account for my artifacts, I was never asked for the used openPG key for the artifact group. What happens if I hand over one of my projects to someone else, who starts uploading the artifacts with a different openPG key?
Answer: There is BitcoinjEnforcerRules, which appears to be an plugin for Maven's enforcer plugin (that's right it's a plugin for a plugin). It works similar to gradle-witness, which means it compares the checksum of (hopefully) all used artifact dependencies to a list you have previously created.
While it's better then nothing, an ideal solution would be if one could simply set the checksum (or the openPG key used to sign the POM in case it's an snapshot artifact) for the POM of direct dependencies, and the POM of those dependencies would contain the checksum of it's artifacts, and the checksum (/openPG key, if snapshot) of the POM of its direct dependencies, and so on.
Note that if checksums are used, then they should be tied to a particular maven repository, since the same (non-changing, i.e. non-snapshot) artifact may have different checksums in different repositories.


Indicator function expression for two sample test

Question: I am trying to understand the theory of this paper. Basically, the paper tries to lay down a framework for using two sample tests using binary classifiers. Let there be two samples $S_p$~$P^n$ and $S_Q$~$Q^m$ So they construct a dataset by pairing the $n$ samples in $S_p$ with a positive label and $m$ samples from $S_Q$ with a negative label. They hypothesize that if the null hypothesis $P=Q$ is true, then the classification accuracy of the binary classifier will remain near chance level. Below the four steps to follow:
Step1: Make the dataset as mentioned above. $D={(x_i,0)_{i=1}^n \cup (y_i,1)_{i=1}^n }= : {(z_i,l_i)}_{i=1}^{2n}$ i.e  pair n examples of each class 0 and 1.
Step 2: Randomly shuffle $D$ and split it into disjoint training and testing subsets $D_{tr}$ and $D_{te}$ where $D=D_{tr} \cup D_{te}$ and $n_{te}=|D_{te}|$
Step 3: Train a binary classifier $f:X \to[0,1]$ on $D_{tr}$
Step 4: We assume that $f(z_i)$ is an estimate of the conditional probability distribution $p(l_i=1|z_i)$. The classification accuracy on $D_{te}$ is given by:
$t=1/n_{te} * \Sigma_{(z_i,l_i)} I [ I (f(z_i) > 0.5) = l_i]$
My question lies in this step. What are they trying to do actually? Why is there a $1/2$ in the equation? It seems like they are trying to find the classification accuracy which is the number of corresctly classified examples divided by the total number of examples. Is that true?
Answer: Their function $f$ has output range $[0, 1]$, but they're turning that into a hard class prediction with $I(f(z_i) > 0.5)$. It's the same thing as saying: if $f$ outputs 0.4, you want to round it to 0; if it outputs 0.500001, you round that to 1. Then the classification accuracy is the portion of the time that this rounded label, $I(f(z_i) > 0.5)$, is equal to the true label $l_i$.
In this paper, they don't actually do anything with the continuous part of $f$; they could equally well have just used a function $g : X \to \{0, 1\}$ and talk about the accuracy of that, $I(g(z_i) = l_i)$.
Comment: 1. Thanks a lot for clarifying. So basically I would take equal number of samples from each class, shuffle them and divide them into train and test data. after that train a binary classifier on the train data. Use this trained model on test data to give out probabilities instead of binary values. Now follow the above rule like you said ($I(f(z_i) > 0.5$) as one or else zero. So this way I will get classification accuracy on test data.


How to prove that $G$ is semidirect product?

Question: If $ N\triangleleft G $ and $ G / N $ is a free group, I want to show that $ G $ is a semi-direct product of $ N $ by $ G / N $, but I don't see how to prove it, I know if $ N $ is normal to $ G $, then $ G $ is a semi-direct product of $ N $ and $ G / N $ if and only if there is a homomorphism $s: G / N \to G$ such that $v\circ s: G/N \to G/N = id$, where $v: G\to G/N$ is the natural projection. but I don't know where to put the hypothesis that $ G / N $ is a free group.
Answer: Basically, free groups are projective, so every surjection onto a free group has a section. Explicitly:
If $G/N$ is a free group, say it is (isomorphic to) a free group on the set $X$. For each $x\in X$, let $g_x\in G$ be such that $\pi(g_x)=x$, where $\pi\colon G\to G/N$ is the canonical projection.. By the universal property of the free group, there exists a group homomorphism $f\colon G/N\to G$ such that $f(x)=g_x$ for each $x\in X$. Since $\pi\circ f$ is the identity on $X$, the universal property of the free group tells us that $\pi\circ f=\mathrm{id}_{G/N}$, and so it follows that $f$ is one-to-one. Therefore, $G$ contains a subgroup isomorphic to $G/N$.
Now verify that $f(G/N)\cap N=\{e\}$ and that $G$ is generated by $N$ and $f(G/N)$.


How to show the value of the value of the variable in batch file?

Question: @echo off
set a=b
set b=c
echo %%a%%

It doesn't work, it only shows %b%. I want to make it to show c. I don't know why if it is only the version of the OS (Windows 7 Ultimate Service Pack 1) or it really wouldn't work.
Answer: you need another parsing layer: Either:
call echo %%%a%%%

in batchfiles, or on command line:
call echo %%a%%

or using delayed expansion:
setlocal enabledelayedexpansion
set a=b
set b=c
echo !%a%!


App crashes when I want to use tableview.deleteRows(at: , with: )

Question: I already saw many topics on this subject but I still have the error...
Here is my code in the tableview delegate method (is called when the user swipe and click on the delete button on the cell):
self.tableView.beginUpdates()

if self.data[sectionType]!.isEmpty {
    self.data.removeValue(forKey: sectionType)
}

self.tableView.deleteRows(at: [indexPath], with: .fade)
self.tableView.endUpdates()

I have implemented the numberOfSections delegate method like this:
func numberOfSections(in tableView: UITableView) -> Int {
    return data.count
}

And this is the error I get:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView internal bug: unable to generate a new section map with old section count: 1 and new section count: 0'
I get the same error if I replace deleteRows(in tableView) method by reloadData()...
I checked with breakpoint, I enter in the if condition when the error occured. So the data is updated (0 element after the removeValue() call) and I call the deleteRows method.
Thanks for your help.
Comment: Did you use the numberOfRowsInSection method?
Answer: Are you trying to delete a row or a section?
if self.data[sectionType]!.isEmpty {
    self.data.removeValue(forKey: sectionType)
}

Suggests you are trying to delete a section. If you are it should be followed by something of this sort:
let indexSet = NSMutableIndexSet()
indexSet.addIndex(section)
self.tableView.deleteSections(indexSet, withRowAnimation: .fade)

If you are trying to delete a row then change the top part to something like this:
if self.data[sectionType]!.isEmpty {
    self.data[sectionType].remove(at: rowToRemove)
}

Comment: You'r totally right ! I wanted to delete a section. I didn't use the right method of UITableView. deleteSections() method fixed my issue :)
Thanks !!
Answer: It looks like you might be deleting all your rows in the section, instead of the one cell.
I'm assuming self.data is a dictionary where the keys are sections and the the values are arrays containing cell information.
Instead of deleting the key to the dictionary. Like you have here...
self.data.removeValue(forKey: sectionType)

You might want to access the section and remove just that row. Something like this...
data[sectionType]?.remove(at: indexPath.row)

I assume the return value you have for the method numberOfRowsInSection: is something similar to...
return data[sectionType]?.count

Hope this helps in someway.


Exibir dado no textView

Question: Tenho um banco de dados em uma aplicação do android, gostaria que o nome campo que há na tabela, preenchesse o text do TextView. Vi alguns exemplos mas não consegui implementar, o  getReadableDatabase().rawQuery(sqlNome, null); sempre fica em vermelho, ou seja, não consigo utilizá-lo. É somente um dado que estará na tabela.
Segue o código que tentei implementar:
criaBanco = new CriaBanco(getBaseContext());
sqlNome = "select nome from tabela";
Cursor cursor = getReadableDatabase().rawQuery(sqlNome, null);

textView = (TextView) findViewById(R.id.txt1);
if (!criaBanco.NOME.isEmpty()) {
    textView.setText(sqlNome);
}
else {
    textView.setText("NOME");
}

cursor.close();

Comment: Não será `Cursor cursor = criaBanco.getReadableDatabase().rawQuery(sqlNome, null);`?
Comment: @ramaral vc está correto. obrigado. Coloque como resposta para que possa marcá-la e colocar 1 voto.
Answer: Bom dia Henrique,
O método getReadableDatabase() deve ser executado no seu banco de dados.
SQLiteDatabase db = criaBanco.getReadableDatabase();
Cursor cursor = db.rawQuery(sqlNome,null);
 if (cursor != null && cursor.moveToFirst()) {
                       cursor.moveToFirst();
                       String txt = cursor.getString(cursor.getColumnIndex(nomeColuna));

                   }

Isso deve te retornar a String e então é só usar o textView.setText(txt);
O código acima retorna somente o primeiro resultado, seu select parece permitir o retorno de todos os dados, se quiser retornar vários registros, após o cursor.moveToFirst() faça um do while com a condição moveToNext()
do{

}while(cursor .moveToNext());

Comment: Obrigado! Neste caso realmente só tem um resultado. Somente há a inserção de 1 dado, o restante é somente update.
Answer: getReadableDatabase() é um método da classe SQLiteOpenHelper.
Suponho que a classe CriaBanco herde dela, assim, pode aceder a esse método e executar a query, desta forma:
Cursor cursor = criaBanco.getReadableDatabase().rawQuery(sqlNome, null);

Exibir dado no textView