1

I am working in some code development related to clinical study. I have multiple visits, like baseline, week 01, and so on. To avoid the use of multiple IF-ELSE statements for assigning numeric values to these visits, I just creating formats using format procedure.

proc format;
 value _vis $ 'baseline'='1'
            'week01'='2'
            'week02'='3' ;
run;

But I am looking for is like baseline having a value 1(numeric) not character. Is there any way out for this problem. Please help.

2
  • It would really help if you could advise how you are using the formatted values Commented Sep 30, 2013 at 10:11
  • FORMAT shows SAS how to display in character a value (either numeric or character). INFORMAT shows SAS how to convert to numeric a value (either character or numeric). Commented Sep 30, 2013 at 13:34

2 Answers 2

3

Simply change your format to an informat...

proc format;
  invalue vis /* INvalue = informat */
    'baseline' = 1
    'week01'   = 2
    'week02'   = 3 
  ;
run;

data data1 ;
  d = 'baseline' ;
  n = input(d,VIS.) ;
run ;
proc print ; run ;

Sign up to request clarification or add additional context in comments.

Comments

0
proc format;
 value $_vis 
'baseline'='1'
'week01'='2'
'week02'='3';
run;

data test;
length vis $8.;
vis = 'baseline';
output;
vis = 'week01';
output;
vis = 'week02';
output;
run;

data test2;
set test;
vis2=vis;
format vis2 _vis.;
vis3=input(put(vis2, _vis.),8.);
run;

test2:

vis     vis2    vis3
baseline    1   1
week01      2   2
week02      3   3

where vis & vis2 are character variables and vis3 is a numeric variable.

Is this what you are looking for?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.