BookmarkSubscribeRSS Feed
mgerberhome0
Calcite | Level 5

Hi,

 

How can I write this as a datastep to change the actual values stored in the variable 'LBTEST' in 9.4?

 

If I use the below Proc format and then Proc Print the updated values show, but how can I save the updated dataset?

 

proc format;
value $LBTEST

        'Albumin (Alb)'='Albumin'
       'Alanine aminotransferase (ALT)'='Alanine aminotransferase'
       'Alkaline phosphatase (ALP)'='Alkaline phosphatase'
      'Aspartate aminotransferase (AST)'='Aspartate aminotransferase'
   'Basophils - % (Baso %)'='Basophils (%)'
  'Basophils - Absolute (Baso Abs)'='Basophils (Abs)'
 'Blood urea nitrogen (BUN)'='Blood urea nitrogen'
run;

 

proc print data=ABNLABKEEP;
format LBTEST $LBTEST.;
run;

5 REPLIES 5
novinosrin
Tourmaline | Level 20

Do you mean ?:

data ABNLABKEEP;

set ABNLABKEEP;

format LBTEST $LBTEST.;
run;

 

Astounding
PROC Star

To actually change the values:

 

data WANT;

set ABNLABKEEP;

LBTEST = put(LBTEST, $LBTEST.);
run;

mgerberhome0
Calcite | Level 5

Thanks!

 

I get an error.... SnipImage.JPG

art297
Opal | Level 21

I have to guess that you made some kind of mistake in creating the format. The following works for me:

data ABNLABKEEP;
  informat lbtest $80.;
  input lbtest &;
  cards;
Albumin (Alb)
Alanine aminotransferase (ALT)
Alkaline phosphatase (ALP)
Aspartate aminotransferase (AST)
Basophils - % (Baso %)
Basophils - Absolute (Baso Abs)
Blood urea nitrogen (BUN)
;

proc format;
value $LBTEST
        'Albumin (Alb)'='Albumin'
       'Alanine aminotransferase (ALT)'='Alanine aminotransferase'
       'Alkaline phosphatase (ALP)'='Alkaline phosphatase'
      'Aspartate aminotransferase (AST)'='Aspartate aminotransferase'
   'Basophils - % (Baso %)'='Basophils (%)'
  'Basophils - Absolute (Baso Abs)'='Basophils (Abs)'
 'Blood urea nitrogen (BUN)'='Blood urea nitrogen'
run;

data WANT;
set ABNLABKEEP;
LBTEST = put(LBTEST, $LBTEST.);
run;

Art, CEO, AnalystFinder.com

 

ballardw
Super User

Or perhaps make that format an INVALUE and use it as an INFORMAT to read the data. This may be a better option in the long run if you are reading multiple files with the same contents.

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 Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1427 views
  • 0 likes
  • 5 in conversation