BookmarkSubscribeRSS Feed
eudox
Calcite | Level 5

Hi everyone.

 

Please assist me in creating a code book.

I have typed out the label and formats.

I need a pdf or word document showing what all the categorical variable values stand for.

I am trying to follow steps on the internet but not winning.

 

This is what I tried to do:

 

libname long "P:\RICE Project\Check\MergeProject";
libname library 'P:\RICE Project\Check\Do files\labels';
run;
title1 RICE study codebook;

%let organization=(ID);
%macro proc codebook(lib=ProjectLong,file1=label_book,fmtlib=work,pdffile= "P:\RICE Project\Check\Do files\labels\ricecb.pdf");
ods listing close;

 

I actually don't understand what I need to write for %let organization??

 

Will appreciate your help.

 

 

 

 

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I do not know what a code book is.  If you want to print the formats list then use the cntlout option in proc format to create a dataset, then proc report that dataset.  There is plenty wrong in the code you present:

libname long "P:\RICE Project\Check\MergeProject";
libname library 'P:\RICE Project\Check\Do files\labels';
run; <- not needed
title1 RICE study codebook; <- titles should be in quotes

%let organization=(ID);  <- this sets organisation macro variable to the string "(ID)"
%macro proc codebook(lib=ProjectLong,file1=label_book,fmtlib=work,pdffile= "P:\RICE Project\Check\Do files\labels\ricecb.pdf");

<- in the above you cannot have the word proc, is this a macro definition as I see no code underneath it?
ods listing close;  <- what is this for?

Shmuel
Garnet | Level 18

Please post what do have, what kind of file is it?

and describe what do you want to achieve, what kind of output - 

is it a sas dataset? an external file or a print listing?

eudox
Calcite | Level 5

Hi all thanks for your responses.

 

I have attached the document where I got the code.

There is also an example of a code book.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes, that paper is 8 years old.  I would suggest you look at an industry standard - CDISC - in particular define documents, but maybe in this case one of the earlier in the chain models.

TomKari
Onyx | Level 15

Here's a rejigged program based on your example and on the document that you provided, that might work. I'm not sure if the pdffile parameter is okay, you might have to change it to pdffile=ricecb.pdf and see where the macro puts the file.

 

The organization macro variable is supposed to indicate the file organization, in their example it is "One Record per Participant (ID)".

 

Tom

 

libname long "P:\RICE Project\Check\MergeProject";
libname library 'P:\RICE Project\Check\Do files\labels';
run;
title1 RICE study codebook;

%let organization=(ID);
%proc_codebook(lib=long,file1=label_book,fmtlib=work.formats,pdffile="P:\RICE Project\Check\Do files\labels\ricecb.pdf");
run;
ods listing close;

TomKari
Onyx | Level 15

The code that you are posting isn't functional. Where did you get it? If we have a look at the original document, we might be able to provide some useful information.

 

Tom

ballardw
Super User

Provide either the code for the macro or what you need in your code book.

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!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 2489 views
  • 0 likes
  • 5 in conversation