Help using Base SAS procedures

Calculation of Baseline values

Accepted Solution Solved
Reply
Contributor
Posts: 64
Accepted Solution

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=avalSmiley Wink"**

Input
AVISITBASE
Baseline23
Baseline25
WEEK 2.
WEEK 2.
WEEK 4.
WEEK 6.

Output

AVISITBase
Baseline24
Baseline24
WEEK 224
WEEK 224
WEEK 424
WEEK 624
Attachment

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

Re: Calculation of Baseline values

Posted in reply to DR_Majeti

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

View solution in original post


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

Re: Calculation of Baseline values

Posted in reply to DR_Majeti

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: 64

Re: Calculation of Baseline values

Posted in reply to Murray_Court

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

Contributor
Posts: 45

Re: Calculation of Baseline values

Posted in reply to DR_Majeti

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: 64

Re: Calculation of Baseline values

Posted in reply to Murray_Court

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

Contributor
Posts: 64

Re: Calculation of Baseline values

Posted in reply to DR_Majeti

Hi murray_court ,

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 1686 views
  • 3 likes
  • 2 in conversation