BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DR_Majeti
Quartz | Level 8

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
AVISITBASE
Baseline23
Baseline25
WEEK 2.
WEEK 2.
WEEK 4.
WEEK 6.

Output

AVISITBase
Baseline24
Baseline24
WEEK 224
WEEK 224
WEEK 424
WEEK 624
1 ACCEPTED SOLUTION

Accepted Solutions
Murray_Court
Quartz | Level 8

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

5 REPLIES 5
Murray_Court
Quartz | Level 8

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

DR_Majeti
Quartz | Level 8

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

Murray_Court
Quartz | Level 8

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.

DR_Majeti
Quartz | Level 8

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

DR_Majeti
Quartz | Level 8

Hi murray_court ,

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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