I am curious to know whether there exists any data set that forces users to publicly release any source code written to analyse it.
Open data licenses apparently do exist, for instance, Open Data Commons maintains the ODbL. I don't think that this has a restriction on code used for analysis, but it does put a share-alike restriction on any derivative datasets.
If you publicly use any adapted version of this database, or works produced from an adapted database, you must also offer that adapted database under the ODbL.
This essentially ensures that the derived database (or steps used to create it) used for analysis must be shared, though not necessarily the analysis itself.
I imagine that you could modify this license to mandate that you share the steps used to create any work produced (i.e. the analysis code) as well under some kind of open license, but I am not a lawyer, and I did not find an existing license that does this in my (short) search. In particular, this could easily be troublesome if you use closed-source third-party software in your analysis (e.g. Stata, Matlab), though people have overcome similar issues with GPL licenses.
The data user agreement for this dataset (MIMIC/eICU) requires users to share their code. https://physionet.org/pnw/a/manage-duas :
If I openly disseminate my results, I will also contribute the code used to produce those results to a defined PhysioNet repository (physionet.org/physiotools/repository/) that is open to the research community.