As a clinical trial statistician or programmer, answer three short questions in Your review: the task, the inputs and outputs, and the AI-assisted review. Agreeing with all three approves this benchmark; disagreeing with any needs a comment. Propose a fix with the Edit button on any source file, or add it to your comments.
We suggest spending no more than 5 minutes on a review. The other tabs beside Your review are background for assessment, not under review.
Summary
README.mdPublic entries: Python and R. Passing coverage requires an installed inventory.
Goal: carry each questionnaire item response into PARAMCD, PARAM, and
AVAL, and add one scale score record per scale per visit, coded F1SCORE,
F2SCORE, SSCORE, and GSCORE, holding the mean answered-item response
transformed to a zero to one hundred scale.
Input: collected questionnaire responses for a ten-item instrument, with
study, subject, and visit (STUDYID, USUBJID, VISIT), category
(QSCAT), test code and test name (QSTESTCD, QSTEST), and numeric result
(QSSTRESN): four physical functioning items and two role functioning items
on the one to four answer scale, three fatigue and sleep symptom items on the
one to four answer scale, and two global health items on the one to seven
answer scale.
Variables:
PARAMCD: the test code (F101throughF104,F201,F202,S01,S02,G01,G02) on an item record, or the scale code (F1SCORE,F2SCORE,SSCORE,GSCORE) on an added score record.PARAM: the test name on an item record, or the scale name on the added score record.AVAL: on an item record, the numeric result on its answer scale, empty when the item was not answered; on a score record, the scale's mean answered-item response on a zero to one hundred scale, where the functioning scales read higher for better functioning, the symptom scale reads higher for worse symptoms, and the global scale reads higher for better health; empty when too few of the scale's items were answered.
Note: every visit with an anchor item record (F101, F201, S01, or
G01), answered or not, carries that scale's score record, so a visit with
too few answers to score keeps an empty score and stays apart from a visit
with no records at all. One item, F104, belongs to two scales and feeds
both of their scores.
Inputs
Under review1 source fileinput/qs.csv
Edit14 rows| STUDYID | USUBJID | VISIT | QSSEQ | QSCAT | QSTESTCD | QSTEST | QSSTRESN |
|---|---|---|---|---|---|---|---|
| MSQ1 | BASELINE | 1 | PHYSICAL FUNCTIONING SCALE | F101 | Difficulty lifting heavy objects | 2 | |
| MSQ1 | BASELINE | 2 | PHYSICAL FUNCTIONING SCALE | F102 | Difficulty walking a long distance | 2 | |
| MSQ1 | BASELINE | 3 | PHYSICAL FUNCTIONING SCALE | F103 | Difficulty walking a short distance | 2 | |
| MSQ1 | BASELINE | 4 | PHYSICAL FUNCTIONING SCALE | F104 | Needing to rest during the day | 2 | |
| MSQ1 | BASELINE | 5 | ROLE FUNCTIONING SCALE | F201 | Limits in doing work or daily activities | 2 | |
| MSQ1 | BASELINE | 6 | ROLE FUNCTIONING SCALE | F202 | Limits in pursuing hobbies or leisure activities | 3 | |
| MSQ1 | BASELINE | 7 | FATIGUE AND SLEEP SYMPTOM SCALE | S01 | Feeling tired during the day | 2 | |
| MSQ1 | BASELINE | 8 | FATIGUE AND SLEEP SYMPTOM SCALE | S02 | Trouble falling asleep | 2 | |
| MSQ1 | BASELINE | 9 | GLOBAL HEALTH SCALE | G01 | Rating of overall health | 4 | |
| MSQ1 | BASELINE | 10 | GLOBAL HEALTH SCALE | G02 | Rating of overall quality of life | 5 | |
| MSQ1 | BASELINE | 1 | PHYSICAL FUNCTIONING SCALE | F101 | Difficulty lifting heavy objects | 3 | |
| MSQ1 | BASELINE | 2 | ROLE FUNCTIONING SCALE | F201 | Limits in doing work or daily activities | 4 | |
| MSQ1 | BASELINE | 3 | FATIGUE AND SLEEP SYMPTOM SCALE | S01 | Feeling tired during the day | — | |
| MSQ1 | BASELINE | 4 | GLOBAL HEALTH SCALE | G01 | Rating of overall health | 7 |
Expected output
Under review22 expected rowsexpected/adqs.csv
Edit22 rows| STUDYID | USUBJID | VISIT | PARAMCD | PARAM | AVAL |
|---|---|---|---|---|---|
| MSQ1 | BASELINE | F101 | Difficulty lifting heavy objects | 2 | |
| MSQ1 | BASELINE | F102 | Difficulty walking a long distance | 2 | |
| MSQ1 | BASELINE | F103 | Difficulty walking a short distance | 2 | |
| MSQ1 | BASELINE | F104 | Needing to rest during the day | 2 | |
| MSQ1 | BASELINE | F201 | Limits in doing work or daily activities | 2 | |
| MSQ1 | BASELINE | F202 | Limits in pursuing hobbies or leisure activities | 3 | |
| MSQ1 | BASELINE | S01 | Feeling tired during the day | 2 | |
| MSQ1 | BASELINE | S02 | Trouble falling asleep | 2 | |
| MSQ1 | BASELINE | G01 | Rating of overall health | 4 | |
| MSQ1 | BASELINE | G02 | Rating of overall quality of life | 5 | |
| MSQ1 | BASELINE | F101 | Difficulty lifting heavy objects | 3 | |
| MSQ1 | BASELINE | F201 | Limits in doing work or daily activities | 4 | |
| MSQ1 | BASELINE | S01 | Feeling tired during the day | — | |
| MSQ1 | BASELINE | G01 | Rating of overall health | 7 | |
| MSQ1 | BASELINE | F1SCORE | Physical Functioning Scale Score | 66.66666666666667 | |
| MSQ1 | BASELINE | F1SCORE | Physical Functioning Scale Score | — | |
| MSQ1 | BASELINE | F2SCORE | Role Functioning Scale Score | 50 | |
| MSQ1 | BASELINE | F2SCORE | Role Functioning Scale Score | 0 | |
| MSQ1 | BASELINE | SSCORE | Fatigue and Sleep Symptom Scale Score | 33.333333333333336 | |
| MSQ1 | BASELINE | SSCORE | Fatigue and Sleep Symptom Scale Score | — | |
| MSQ1 | BASELINE | GSCORE | Global Health Scale Score | 58.333333333333336 | |
| MSQ1 | BASELINE | GSCORE | Global Health Scale Score | 100 |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADQS | STUDYID | Study Identifier | character | Copy value from QS.STUDYID. | Predecessor | ||
| ADQS | USUBJID | Unique Subject Identifier | character | Copy value from QS.USUBJID. | Predecessor | ||
| ADQS | VISIT | Visit Name | character | Copy value from QS.VISIT. | Predecessor | ||
| ADQS | PARAMCD | Parameter Code | character | F101, F102, F103, F104, F201, F202, S01, S02, G01, G02, F1SCORE, F2SCORE, SSCORE, GSCORE | Set per constructed row; see the Row construction sheet. | Derived | |
| ADQS | PARAM | Parameter | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADQS | AVAL | Analysis Value | numeric | Set per constructed row; see the Row construction sheet. | Derived |
| Template | Include when | PARAMCD | PARAM | ITEMRESN | SCALE_ANCHOR | SCALE_SUM | SCALE_ANS | AVAL | STUDYID | USUBJID | VISIT |
|---|---|---|---|---|---|---|---|---|---|---|---|
| item | Copy QS.QSTESTCD | Copy QS.QSTEST | Copy QS.QSSTRESN | Constant "None" | Constant "None" | Constant "None" | Copy ITEMRESN | None | None | None | |
| f1score | SCALE_ANCHOR >= 1 | Constant "F1SCORE" | Constant "Physical Functioning Scale Score" | Constant "None" | Aggregate COUNT(QS.QSTESTCD) over records matching on the shared output keys, where QS.QSTESTCD = 'F101' | Aggregate SUM(QS.QSSTRESN) over records matching on the shared output keys, where QS.QSTESTCD IN ('F101', 'F102', 'F103', 'F104') | Aggregate COUNT(QS.QSSTRESN) over records matching on the shared output keys, where QS.QSTESTCD IN ('F101', 'F102', 'F103', 'F104') | If SCALE_ANS >= 2 then compute 100 * (1 - (SCALE_SUM / SCALE_ANS - 1) / 3); otherwise "None" | Copy QS.STUDYID | Copy QS.USUBJID | Copy QS.VISIT |
| f2score | SCALE_ANCHOR >= 1 | Constant "F2SCORE" | Constant "Role Functioning Scale Score" | Constant "None" | Aggregate COUNT(QS.QSTESTCD) over records matching on the shared output keys, where QS.QSTESTCD = 'F201' | Aggregate SUM(QS.QSSTRESN) over records matching on the shared output keys, where QS.QSTESTCD IN ('F201', 'F202') | Aggregate COUNT(QS.QSSTRESN) over records matching on the shared output keys, where QS.QSTESTCD IN ('F201', 'F202') | If SCALE_ANS >= 1 then compute 100 * (1 - (SCALE_SUM / SCALE_ANS - 1) / 3); otherwise "None" | Copy QS.STUDYID | Copy QS.USUBJID | Copy QS.VISIT |
| sscore | SCALE_ANCHOR >= 1 | Constant "SSCORE" | Constant "Fatigue and Sleep Symptom Scale Score" | Constant "None" | Aggregate COUNT(QS.QSTESTCD) over records matching on the shared output keys, where QS.QSTESTCD = 'S01' | Aggregate SUM(QS.QSSTRESN) over records matching on the shared output keys, where QS.QSTESTCD IN ('S01', 'S02', 'F104') | Aggregate COUNT(QS.QSSTRESN) over records matching on the shared output keys, where QS.QSTESTCD IN ('S01', 'S02', 'F104') | If SCALE_ANS >= 2 then compute 100 * (SCALE_SUM / SCALE_ANS - 1) / 3; otherwise "None" | Copy QS.STUDYID | Copy QS.USUBJID | Copy QS.VISIT |
| gscore | SCALE_ANCHOR >= 1 | Constant "GSCORE" | Constant "Global Health Scale Score" | Constant "None" | Aggregate COUNT(QS.QSTESTCD) over records matching on the shared output keys, where QS.QSTESTCD = 'G01' | Aggregate SUM(QS.QSSTRESN) over records matching on the shared output keys, where QS.QSTESTCD IN ('G01', 'G02') | Aggregate COUNT(QS.QSSTRESN) over records matching on the shared output keys, where QS.QSTESTCD IN ('G01', 'G02') | If SCALE_ANS >= 1 then compute 100 * (SCALE_SUM / SCALE_ANS - 1) / 6; otherwise "None" | Copy QS.STUDYID | Copy QS.USUBJID | Copy QS.VISIT |
| Variable | Permitted values |
|---|---|
| PARAMCD | F101, F102, F103, F104, F201, F202, S01, S02, G01, G02, F1SCORE, F2SCORE, SSCORE, GSCORE |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.7 | 2026-10-20 | yamaa docs build | Read a specification in the 1.0 surface as its 0.5 counterpart; state that missing values stay missing where a mapping declares no missing handler, and leave out a declared missing answer that restates a handler's default | ||
| 1.6 | 2026-10-17 | yamaa docs build | Describe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight | ||
| 1.5 | 2026-10-17 | yamaa docs build | Name collected precision in words instead of letter codes; state imputation fallbacks, minimum source precision, bounds ignored outside the collected period, and invalid text with no handler as an error; describe date and datetime shifts, imputation flag codes, and partial text giving no date part | ||
| 1.4 | 2026-10-15 | yamaa docs build | State datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks | ||
| 1.3 | 2026-09-29 | yamaa docs build | Show study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata | ||
| 1.2 | 2026-09-29 | yamaa docs build | Classify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived | ||
| 1.1 | 2026-09-29 | yamaa docs build | Resolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML | ||
| 1.0 | yamaa docs build | Initial generation from spec.yaml |
prompts/adam-adqs-multi-scale-scoring/full.md
Edit38 linesFollowing CDISC ADaM standards, use the provided QS dataset to create an ADQS dataset with one record per subject, visit, and parameter.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, VISIT, PARAMCD, PARAM, AVAL
PARAMCD on an item record is the item's test code and PARAM is its test name. AVAL on an item record is the item's numeric result on its answer scale, and has no value when the item was not answered. The physical functioning scale holds items F101, F102, F103, and F104, and its score record has PARAMCD "F1SCORE" and PARAM "Physical Functioning Scale Score". The role functioning scale holds items F201 and F202, and its score record has PARAMCD "F2SCORE" and PARAM "Role Functioning Scale Score". The fatigue and sleep symptom scale holds items S01, S02, and F104, and its score record has PARAMCD "SSCORE" and PARAM "Fatigue and Sleep Symptom Scale Score". The global health scale holds items G01 and G02, and its score record has PARAMCD "GSCORE" and PARAM "Global Health Scale Score". AVAL on a score record is the mean of the scale's answered item responses at that visit, rescaled linearly onto a zero to one hundred scale, and is not rounded. On the physical functioning and role functioning scales a mean response of 1 reads 100 and a mean response of 4 reads 0, so a higher score reads as better functioning. On the fatigue and sleep symptom scale a mean response of 1 reads 0 and a mean response of 4 reads 100, so a higher score reads as worse symptoms. On the global health scale a mean response of 1 reads 0 and a mean response of 7 reads 100, so a higher score reads as better health. AVAL on a physical functioning or fatigue and sleep symptom score record has no value when fewer than two of the scale's items were answered at that visit. AVAL on a role functioning or global health score record has no value when none of the scale's items was answered at that visit. A scale's score record is added at a visit only when the visit holds that scale's anchor item record, F101 for physical functioning, F201 for role functioning, S01 for fatigue and sleep symptoms, and G01 for global health, and it is added whether or not the anchor item was answered, so a visit with too few answers keeps its score record with no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adqs.csv.
prompts/adam-adqs-multi-scale-scoring/conventions.md
Edit16 linesFollowing CDISC ADaM standards, use the provided QS dataset to create an ADQS dataset with one record per subject, visit, and parameter.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, VISIT, PARAMCD, PARAM, AVAL
The physical functioning score record has PARAMCD "F1SCORE" and PARAM "Physical Functioning Scale Score". The role functioning score record has PARAMCD "F2SCORE" and PARAM "Role Functioning Scale Score". The fatigue and sleep symptom score record has PARAMCD "SSCORE" and PARAM "Fatigue and Sleep Symptom Scale Score". The global health score record has PARAMCD "GSCORE" and PARAM "Global Health Scale Score". AVAL on a score record is not rounded.
Read the source datasets from /app/input and save the completed dataset as /app/output/adqs.csv.
prompts/adam-adqs-multi-scale-scoring/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided QS dataset to create an ADQS dataset with one record per subject, visit, and parameter.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, VISIT, PARAMCD, PARAM, AVAL
Read the source datasets from /app/input and save the completed dataset as /app/output/adqs.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adqs-multi-scale-scoring/result.R
Edit75 lines# Reference solution for the yamaa benchmark adam-adqs-multi-scale-scoring (R track).## Written from the benchmark's full prompt and its inputs alone, as an agent# would write it. Harbor's oracle agent runs it to check that the prompt can# be solved and that the grader scores a correct answer 1.library(dplyr, warn.conflicts = FALSE)library(purrr, warn.conflicts = FALSE)library(readr)qs <- read_csv( "/app/input/qs.csv", col_types = cols( QSSEQ = col_integer(), QSSTRESN = col_double(), .default = col_character() ))# Each item response, on its own answer scale.items <- qs |> mutate(PARAMCD = QSTESTCD, PARAM = QSTEST, AVAL = QSSTRESN) |> select(STUDYID, USUBJID, VISIT, PARAMCD, PARAM, AVAL)# The four scales: member items, anchor item, minimum answered items,# direction (down = higher score means better, up = higher means worse),# and the answer range.scales <- tribble( ~pcode, ~pname, ~members, ~anchor, ~min_ans, ~direction, ~rng, "F1SCORE", "Physical Functioning Scale Score", list(c("F101", "F102", "F103", "F104")), "F101", 2L, "down", 3, "F2SCORE", "Role Functioning Scale Score", list(c("F201", "F202")), "F201", 1L, "down", 3, "SSCORE", "Fatigue and Sleep Symptom Scale Score", list(c("S01", "S02", "F104")), "S01", 2L, "up", 3, "GSCORE", "Global Health Scale Score", list(c("G01", "G02")), "G01", 1L, "up", 6)score_one <- function(pcode, pname, members, anchor, min_ans, direction, rng) { # `members` arrives as a one-element list from the tribble's list-column; # `%in%` against a list never matches, so unwrap it first. members <- unlist(members) member_rows <- items |> filter(PARAMCD %in% members) visits <- items |> filter(PARAMCD %in% anchor) |> distinct(STUDYID, USUBJID, VISIT) stats <- member_rows |> group_by(STUDYID, USUBJID, VISIT) |> summarise( n_answered = sum(!is.na(AVAL)), raw_mean = mean(AVAL, na.rm = TRUE), .groups = "drop" ) visits |> left_join(stats, by = c("STUDYID", "USUBJID", "VISIT")) |> mutate( AVAL = dplyr::case_when( is.na(n_answered) | n_answered < min_ans ~ NA_real_, direction == "down" ~ 100 * (1 - (raw_mean - 1) / rng), TRUE ~ 100 * (raw_mean - 1) / rng ), PARAMCD = pcode, PARAM = pname ) |> select(STUDYID, USUBJID, VISIT, PARAMCD, PARAM, AVAL)}scores <- pmap_dfr(scales, score_one)adqs <- bind_rows(items, scores) |> arrange(STUDYID, USUBJID, VISIT, PARAMCD)dir.create("/app/output", showWarnings = FALSE)write_csv(adqs, "/app/output/adqs.csv", na = "")solutions/adam-adqs-multi-scale-scoring/result.py
Edit78 lines# Reference solution for the yamaa benchmark adam-adqs-multi-scale-scoring (Python track).## Written from the benchmark's full prompt and its inputs alone, as an agent# would write it. Harbor's oracle agent runs it to check that the prompt can# be solved and that the grader scores a correct answer 1.import csvfrom collections import OrderedDictINPUT = "/app/input"OUTPUT = "/app/output"# scale: (score PARAMCD, PARAM, items, anchor, min answered, rescale fn)SCALES = [ ("F1SCORE", "Physical Functioning Scale Score", ["F101", "F102", "F103", "F104"], "F101", 2, lambda m: (4.0 - m) / 3.0 * 100.0), ("F2SCORE", "Role Functioning Scale Score", ["F201", "F202"], "F201", 1, lambda m: (4.0 - m) / 3.0 * 100.0), ("SSCORE", "Fatigue and Sleep Symptom Scale Score", ["S01", "S02", "F104"], "S01", 2, lambda m: (m - 1.0) / 3.0 * 100.0), ("GSCORE", "Global Health Scale Score", ["G01", "G02"], "G01", 1, lambda m: (m - 1.0) / 6.0 * 100.0),]def fmt(value): if value is None: return "" if float(value).is_integer(): return str(int(value)) return repr(float(value))def main(): with open(f"{INPUT}/qs.csv", newline="") as f: rows = list(csv.DictReader(f)) groups = OrderedDict() # (study, subj, visit) -> list of rows for r in rows: key = (r["STUDYID"], r["USUBJID"], r["VISIT"]) groups.setdefault(key, []).append(r) out = [] for (study, subj, visit), grows in groups.items(): for r in grows: aval = r["QSSTRESN"].strip() out.append([study, subj, visit, r["QSTESTCD"], r["QSTEST"], aval if aval else ""]) by_code = {} for r in grows: by_code.setdefault(r["QSTESTCD"], []).append(r) for pcd, pname, items, anchor, min_n, scale_fn in SCALES: if anchor not in by_code: continue answered = [] for code in items: for r in by_code.get(code, []): v = r["QSSTRESN"].strip() if v: answered.append(float(v)) if len(answered) >= min_n: aval = fmt(scale_fn(sum(answered) / len(answered))) else: aval = "" out.append([study, subj, visit, pcd, pname, aval]) with open(f"{OUTPUT}/adqs.csv", "w", newline="") as f: w = csv.writer(f) w.writerow(["STUDYID", "USUBJID", "VISIT", "PARAMCD", "PARAM", "AVAL"]) w.writerows(out)if __name__ == "__main__": main()solutions/adam-adqs-multi-scale-scoring/result.sas
Edit36 lines/* opensas reference solution for the yamaa benchmark adam-adqs-multi-scale-scoring. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data qs; length STUDYID USUBJID VISIT QSCAT QSTESTCD QSTEST $1024; infile "/app/input/qs.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. VISIT : $char1024. QSSEQ QSCAT : $char1024. QSTESTCD : $char1024. QSTEST : $char1024. QSSTRESN;run;proc sql; create table collected as select STUDYID,USUBJID,VISIT,QSTESTCD as PARAMCD,QSTEST as PARAM,QSSTRESN as AVAL from qs; quit;proc sql;create table anchor0 as select distinct STUDYID,USUBJID,VISIT from collected where PARAMCD='F101';create table members0 as select * from collected where PARAMCD in ('F101','F102','F103','F104');create table stats0 as select a.STUDYID,a.USUBJID,a.VISIT,count(b.AVAL) as NANSWER,mean(b.AVAL) as RAWMEAN from anchor0 a left join members0 b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.VISIT=b.VISIT group by a.STUDYID,a.USUBJID,a.VISIT; quit;data score0; set stats0; length PARAMCD PARAM $1024; PARAMCD='F1SCORE'; PARAM='Physical Functioning Scale Score'; AVAL=.; if NANSWER>=2 then AVAL=100*(1-(RAWMEAN-1)/3); run;proc sql;create table anchor1 as select distinct STUDYID,USUBJID,VISIT from collected where PARAMCD='F201';create table members1 as select * from collected where PARAMCD in ('F201','F202');create table stats1 as select a.STUDYID,a.USUBJID,a.VISIT,count(b.AVAL) as NANSWER,mean(b.AVAL) as RAWMEAN from anchor1 a left join members1 b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.VISIT=b.VISIT group by a.STUDYID,a.USUBJID,a.VISIT; quit;data score1; set stats1; length PARAMCD PARAM $1024; PARAMCD='F2SCORE'; PARAM='Role Functioning Scale Score'; AVAL=.; if NANSWER>=1 then AVAL=100*(1-(RAWMEAN-1)/3); run;proc sql;create table anchor2 as select distinct STUDYID,USUBJID,VISIT from collected where PARAMCD='S01';create table members2 as select * from collected where PARAMCD in ('S01','S02','F104');create table stats2 as select a.STUDYID,a.USUBJID,a.VISIT,count(b.AVAL) as NANSWER,mean(b.AVAL) as RAWMEAN from anchor2 a left join members2 b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.VISIT=b.VISIT group by a.STUDYID,a.USUBJID,a.VISIT; quit;data score2; set stats2; length PARAMCD PARAM $1024; PARAMCD='SSCORE'; PARAM='Fatigue and Sleep Symptom Scale Score'; AVAL=.; if NANSWER>=2 then AVAL=100*(RAWMEAN-1)/3; run;proc sql;create table anchor3 as select distinct STUDYID,USUBJID,VISIT from collected where PARAMCD='G01';create table members3 as select * from collected where PARAMCD in ('G01','G02');create table stats3 as select a.STUDYID,a.USUBJID,a.VISIT,count(b.AVAL) as NANSWER,mean(b.AVAL) as RAWMEAN from anchor3 a left join members3 b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.VISIT=b.VISIT group by a.STUDYID,a.USUBJID,a.VISIT; quit;data score3; set stats3; length PARAMCD PARAM $1024; PARAMCD='GSCORE'; PARAM='Global Health Scale Score'; AVAL=.; if NANSWER>=1 then AVAL=100*(RAWMEAN-1)/6; run;data result; length PARAMCD PARAM $1024; set collected score0 score1 score2 score3; run;proc sql; create table final as select STUDYID, USUBJID, VISIT, PARAMCD, PARAM, AVAL from result;quit;proc export data=final outfile="/app/output/adqs.csv" dbms=csv replace; run;
yamaa