BookmarkSubscribeRSS Feed
TANMOY05
Obsidian | Level 7
libname raw "/folders/myfolders/cliniops/REN002/tables" ;

%let outpath=/folders/myfolders/cliniops/REN002/tables ;
%let pgmname=t14_2_1 ;

* options byline ;
%let tst=* ;


proc format;
	value visf -1='Screening'
				0='Baseline'
				2='02 hrs'
				4='04 hrs'
				8='08 hrs'
				12='12 hrs'
				18='18 hrs'
				24='24 hrs'
				48='48 hrs'
				72='72 hrs'
				96='96 hrs'
				168='168 hrs' ;
	value sumf	1='Visit Value'
				2='Change'
				3='% Change' ;
	value $stf 'NV'='N'
			   'MV'='Mean'
			   'SV'='SD'
			   'DV'='Median'
			   'IV'='Min'
			   'AV'='Max' ;
	value $st2f 'NV'='N'
			    'MV'='GeoMean[1]'
			    'SV'='GeoCV%[2]'
			    'DV'='Median'
			    'IV'='Min'
			    'AV'='Max' ;
run ;

proc import datafile = '/folders/myfolders/cliniops/excel data files/programs/subset1.csv'
out = raw.renibus
dbms = csv
replace;
run;

/*data cm ;
	length SUBJECT $8 ;
	set renibus ;
	if CMTRT__CMD__CM__logs^='' ;
	subject=put(subject_id,z3.) ;
	rename 	CMDOCYN__CMD__CM__logs=CMDOCYN
			CMDOSFRM__CMD__CM__logs=CMDOSFRM
			CMDOSFRQ__CMD__CM__logs=CMDOSFRQ
			CMENDAT__CMD__CM__logs=CMENDAT
			CMINDC__CMD__CM__logs=CMINDC
			CMONGO__CMD__CM__logs=CMONGO
			CMPRIOR__CMD__CM__logs=CMPRIOR
			CMROUTE__CMD__CM__logs=CMROUTE
			CMSTDAT__CMD__CM__logs=CMSTDAT
			CMTRT__CMD__CM__logs=CMTRT ;
	keep subject CMDOCYN__CMD__CM__logs CMDOSFRM__CMD__CM__logs CMDOSFRQ__CMD__CM__logs CMENDAT__CMD__CM__logs CMINDC__CMD__CM__logs
		 CMONGO__CMD__CM__logs CMPRIOR__CMD__CM__logs CMROUTE__CMD__CM__logs CMSTDAT__CMD__CM__logs CMTRT__CMD__CM__logs ;
run ;*/


PROC IMPORT OUT= raw.lab 
            DATAFILE= "/folders/myfolders/cliniops/excel data files/programs/CliniOps-Renibus-Lab-REN-002-Jan-16-2019-1.xlsx" 
            DBMS=xlsx REPLACE;
RUN;


data adsl ;
	length SUBJECT STRATUM $8 ;
	set raw.renibus ;
	if I_SCNNO__HEADER__CKDIE__ScrVST not in ('.','') then stratum='CKD' ;
	if I_SCNNO__HEADER__HVIE__ScrVst  not in ('.','') then stratum='HV' ;
	if stratum='' then delete ;
	subject=put(subject_id,z3.) ;
	COHORT=strip(COHORT__COHORT__ALSUBJSCN_ScrVst) ;
	TYPE=strip(INIE_COHORT_ALSUBJSCN_Screen);	 *1=HV, 2=CKD ;
	keep subject stratum cohort type ;
run ;

data lb ;
	length SUBJECT TESTCD $8  VISIT $24 ;
	set raw.lab ;
	subject=substr(subject_id,2,3) ;
	if test in ('Ferritin','Haptoglobin','Plasma HO-1','Plasma Hemopexin','Plasma P21') ;* 'INTERLEUKIN10' ;
	if      test='Ferritin'         then testcd='FE' ;
	else if test='Haptoglobin'      then testcd='HPG' ;
	else if test='INTERLEUKIN10'    then testcd='IL10' ;
	else if test='Plasma HO-1'      then testcd='PHO1' ;
	else if test='Plasma Hemopexin' then testcd='PHPX' ;
	else if test='Plasma P21'       then testcd='PP21' ;
	if index(visit,'Screening')>0 then visit='Screening Visit' ;
	if visit='Study Day 1-2HR' then visit='Study Day 1, 02HR' ;
	if visit='Study Day 1-4HR' then visit='Study Day 1, 04HR' ;
	if visit='Study Day 1-8HR' then visit='Study Day 1, 08HR' ;
	if visit='Study Day 1-12HR' then visit='Study Day 1, 12HR' ;
	if visit='Study Day 1-18HR' then visit='Study Day 1, 18HR' ;
	if visit='Study Day 1-Basel' then visit='Study Day 1' ;
	if visit='Study Day 2-Basel' then visit='Study Day 2' ;
	if visit='Study Day 3-Basel' then visit='Study Day 3' ;
	if visit='Study Day 4-Basel' then visit='Study Day 4' ;
	if visit='Study Day 5-Basel' then visit='Study Day 5' ;
	if index(visit,'Screening')>0 then VISITN=-1 ;
	if index(visit,'02HR')>0 then visitn=2 ;
	if index(visit,'04HR')>0 then visitn=4 ;
	if index(visit,'08HR')>0 then visitn=8 ;
	if index(visit,'12HR')>0 then visitn=12 ;
	if index(visit,'18HR')>0 then visitn=18 ;
	if visit='Study Day 1' then visitn=0 ;
	if visit='Study Day 2' then visitn=24 ;
	if visit='Study Day 3' then visitn=48 ;
	if visit='Study Day 4' then visitn=72 ;
	if visit='Study Day 5' then visitn=96 ;
	if visit='Study Day 8' then visitn=168 ;
	if value not in ('-','Plasma','Sample') then aval=input(value,best.) ;
	format visit $char24. ;
run ;

proc sort data=lb ;
	by subject testcd visitn ;
run ;

proc sort data=adsl ;
	by subject ;
run ;

data lb2 ;
	merge lb adsl ;
	by subject ;
	if testcd in ('FE','HPG','PHPX','PP21') ;
run ;

data base ;
	set lb2 ;
	where visitn=0 ;
	rename aval=base ;
	keep subject testcd aval ;
run ;

data lb3 ;
	merge lb2(in=a where=(visitn>=0)) base(in=b) ;
	by subject testcd ;
	if a and b ;
/*	if visitn>0 and aval>. then do ;*/
/*		CHG=aval-base ;*/
/*		PCHG=(aval-base)/base*100 ;*/
/*	end ;*/
	LOGBASE=log(base) ;
	if aval>. then do ;
		LOGAVAL=log(aval) ;
		if visitn>0 then do ;
			CHG=aval-base ;
			CHGLOG=logaval-logbase ;
			PCHG=(aval-base)/base*100 ;
		end ;
	end ;
	output ;
	stratum='HV+CKD' ;
	output ;
run ;

/*
data lb3tmp ;
	set lb3 ;
	logaval=log(aval) ;
run ;

proc sort data=lb3tmp ;
	by test ;
run ;

ods select histogram qqplot testsfornormality ;
proc univariate data=lb3tmp normal ;
	var pchg ;* aval logaval ;
	histogram ;
	qqplot ;
	by test ;
run ;
* USE LOG(FERRITIN), LOG(HAPTOGLOBIN) OR BAPTOGLOBIN, HO-1, LOG(PLASMA HEMOPEXIN), LOG(PLASMA P21) ;
*/

proc sort data=lb3 ;
	WHERE STRATUM='HV' AND TESTCD='FE' ;	
	by stratum testcd visitn cohort ;
run ;

proc summary data=lb3 ;
	var logaval ;
	by stratum testcd test visitn cohort ;
	output out=visval n=nv mean=mv std=sv median=dv min=iv max=av cv=cv ; 
run ;

proc summary data=lb3 ;
	where visitn>0 ;
	var chglog ;
	by stratum testcd test visitn cohort ;
	output out=chg n=nv mean=mv std=sv median=dv min=iv max=av cv=cv ; 
run ;

proc summary data=lb3 ;
	where visitn>0 ;
	var pchg ;
	by stratum testcd test visitn cohort ;
	output out=pchg n=nv mean=mv std=sv median=dv min=iv max=av ; 
run ;

data summ ;
	set visval(in=a) chg(in=b) pchg(in=c) ;
	by stratum testcd visitn cohort ;
	if a then sumtyp=1 ;
	if b then sumtyp=2 ;
	if c then sumtyp=3 ;
	if a or b then do ;
		mv=exp(mv) ;	* CONVERT FROM LOG BACK TO ORIGINAL SCALE, THIS IS GEOMETRIC MEAN ;
		sv=sqrt(exp(sv**2)-1)*100 ;* exp(sv) ;* COEFFICIENT OF VARIATION FOR GEOMETRIC MEAN ;
		dv=exp(dv) ;	* MEDIAN, MIN, MAX BACK TO ORIGINAL SCALE ;
		iv=exp(iv) ;
		av=exp(av) ;
	end ;
run ;

proc sort data=summ ;
	by stratum testcd visitn sumtyp cohort ;
run ;

proc transpose data=summ out=summ2 ;
	var nv mv sv dv iv av ;
	by stratum testcd test visitn ;
	id cohort sumtyp ;
run ;

data summ3 ;
	set summ2 ;
	by stratum testcd test visitn ;
	length STAT $44 ;
	stat=put(_name_,$stf.) ;
	array old cohort_11 cohort_12 cohort_13 cohort_21 cohort_22 cohort_23 cohort_31 cohort_32 cohort_33 ;
	array new $20 c11 c12 c13 c21 c22 c23 c31 c32 c33 ;
	do over old ;
		if _name_='NV' then new=put(old,2.) ;
		if _name_ in ('MV','DV') then new=put(old,8.3) ;
		if _name_='SV' then new=put(old,8.4) ;
		if _name_ in ('IV','AV') then new=put(old,8.2) ;
		new=strip(new) ;
		if new='.' then new='' ;
	end ;
run ;

ods select none ;
ods output lsmeans=lsm_aval ;
proc mixed data=lb3 ;
	where visit^='Study Day 1' ;
	by stratum testcd test ;
	class cohort visitn subject ;
	model logaval = cohort visitn cohort*visitn logbase / ddfm=kr2 ;
	repeated visitn / subject=subject type=cs ;* ar(1) ;
	lsmeans cohort*visitn / slice=visitn cl ;
run ;
ods select all ;

i am getting error work.lsm_aval does not exsist, though my code has        ods output lsmeans=lsm_aval ;   

why the dataset lsm_aval is not getting created?

3 REPLIES 3
TANMOY05
Obsidian | Level 7
Yeah , i am getting that error only as the first error in my log file , i.e
Couldn't find work.lsm_aval

ballardw
Super User

When you use ODS SELECT NONE you create NO ods output objects.

So the ODS output has nothing to output from.

 

So, why do you have ODS Select NONE just before the ODS Output???

 

If you only want the LSMEANS then use ODS Select Lsmeans; (or perhaps Mixed.means, may have to turn ods trace on to get the correct full name)

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 500 views
  • 1 like
  • 3 in conversation