Hi all,
I created a lab dataset for calculation of baseline values for avisit values. (BY USUBJID LBSPEC LBCAT PARAMCD AVISIT)
The input looks in the attached picture and csv file.
Output for base line
Base should have average value of baseline of particular paramcd (as given above by statement)
**If base was not present in csv file "then (if avisit='baseline' then base=aval;)"**
Input | |
AVISIT | BASE |
Baseline | 23 |
Baseline | 25 |
WEEK 2 | . |
WEEK 2 | . |
WEEK 4 | . |
WEEK 6 | . |
Output | |
AVISIT | Base |
Baseline | 24 |
Baseline | 24 |
WEEK 2 | 24 |
WEEK 2 | 24 |
WEEK 4 | 24 |
WEEK 6 | 24 |
Hi,
This program should answer your question. Dont have sas on my home pc so cant check for syntax errors unfortunately.
/* calculate 'base' value for each paramcd */
proc sql;
create table baselines as
select paramcd, avg(aval) as base
from LAB
where avisit="baseline"
group by paramcd
;
/*add base value on to each paramcd */
create table output1 as
select a.avisit, b.base
from
LAB as a
inner join
baselines as b
on a.paramcd=b.paramcd
;
quit;
/*print output1 */
proc print data=output1;
run;
Let me know if this helps.
-Murray
Hi,
This program should answer your question. Dont have sas on my home pc so cant check for syntax errors unfortunately.
/* calculate 'base' value for each paramcd */
proc sql;
create table baselines as
select paramcd, avg(aval) as base
from LAB
where avisit="baseline"
group by paramcd
;
/*add base value on to each paramcd */
create table output1 as
select a.avisit, b.base
from
LAB as a
inner join
baselines as b
on a.paramcd=b.paramcd
;
quit;
/*print output1 */
proc print data=output1;
run;
Let me know if this helps.
-Murray
Actually, there are no syntax errors but logical error.. it says no observations with two variables
Error on my part. The string reference needs to be explicit, I had
where avisit="baseline"
whereas what i needed was
where avisit="Baseline"
It should work when the string is referenced properly.
Hey Thank you, for that.. is there any way other than proc sql.. Correct answer
Hi murray_court ,
Please can you give the syntax how to we label a variable in PROC SQL.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.