BookmarkSubscribeRSS Feed
Rabelais
Obsidian | Level 7

@Tom @Quentin So the code by @mkeintz in order to work should be changed in this way (the only differences are at lines 8 and 15). Do you agree?

 

 

proc sql  noprint;
  create view vcars as select 
    case when type='Hybrid' then 'Hyb' 
         when type='Sedan'  then 'Sed' 
         when type='Sports' then 'Spo' 
         when type='Truck'  then 'Trk' 
         else type
    end as type_new
   ,*
  from sashelp.cars;
quit;

data want;
  set sashelp.cars (obs=0)
  vcars(drop=type rename=(type_new=type));
run;

 

 

Kurt_Bremser
Super User

In a case like yours, where the type and length of the variable do not change, this will do it:

data want;
set sashelp.cars;
type = ifc(type = 'Hybrid','Wagon`,type);
run;
sasecn
Quartz | Level 8

Thank you for all the help! Great explanation from everyone 😀

SASKiwi
PROC Star

@sasecn  - Please help us by updating your post as answered if you are happy with the responses.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 19 replies
  • 3347 views
  • 12 likes
  • 10 in conversation