BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
madtex99
Calcite | Level 5

I have this statement written but when I run the code my format statement doesn't print. Any idea what I'm doing wrong?

 

data work.HW6;
        set TMP1.hw6;
proc format;
        value $TestSite 'Thoracic'='T' 'Lumbar-Spine'='LS';
        value TypeOfImaging 1='MRI' 2='CT' 3='Plain';
proc sort data=work.HW6 nodupkey;
        by descending dos;
proc print data=work.HW6;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You would have to associate the Format with the variables that you want to use it.

 

Example: (Assumes that variables Thisvar and Thatvar are in the data set, Thisvar is a character variable and that you want those variables to show the formatted values.

proc print data=work.HW6;
   FORMAT thisvar  $testsite. thatvar TypeofImaging. ;
run;

 

If you want a variable to use a format by default then you make the association permanent by assigning it in a data step or use the utility procedure Datasets to modify the set as such.

The data step version would look like:

data work.HW6;
        set TMP1.hw6;
       format thisvar $testsite. thatvar TypeofImaging. ;
run;

The format does not actually have to exist in your session when assigned the variable but you should make sure it is available when you want to use it.

View solution in original post

1 REPLY 1
ballardw
Super User

You would have to associate the Format with the variables that you want to use it.

 

Example: (Assumes that variables Thisvar and Thatvar are in the data set, Thisvar is a character variable and that you want those variables to show the formatted values.

proc print data=work.HW6;
   FORMAT thisvar  $testsite. thatvar TypeofImaging. ;
run;

 

If you want a variable to use a format by default then you make the association permanent by assigning it in a data step or use the utility procedure Datasets to modify the set as such.

The data step version would look like:

data work.HW6;
        set TMP1.hw6;
       format thisvar $testsite. thatvar TypeofImaging. ;
run;

The format does not actually have to exist in your session when assigned the variable but you should make sure it is available when you want to use it.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 1 reply
  • 71 views
  • 0 likes
  • 2 in conversation