Solved
Contributor
Posts: 72

# Calculation of Baseline values

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

Accepted Solutions
Solution
‎08-20-2013 03:13 AM
Contributor
Posts: 45

## Re: Calculation of Baseline values

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

All Replies
Solution
‎08-20-2013 03:13 AM
Contributor
Posts: 45

## Re: Calculation of Baseline values

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

Contributor
Posts: 72

## Re: Calculation of Baseline values

Actually, there are no syntax errors but logical error.. it says no observations with two variables

Contributor
Posts: 45

## Re: Calculation of Baseline values

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.

Contributor
Posts: 72

## Re: Calculation of Baseline values

Hey Thank you,  for that.. is there any way other than proc sql.. Correct answer

Contributor
Posts: 72

## Re: Calculation of Baseline values

Hi murray_court ,

Please can you give the syntax how to we label a variable in PROC SQL.

🔒 This topic is solved and locked.