BookmarkSubscribeRSS Feed
Allaluiah
Quartz | Level 8

Hello experts,

I have something like

proc format;

value $country

"United states of America"="US"

------

-----

"Russia"= "RU";

run;

about 22 countries list

I would like to know how to use control in and out format if that can be used  to parametrize user defined formats. Is it possible to make this existing proc format statements(like the above) read a new a new list of  different countries and their label by using a parameter?  I see the next list is having countries staring from "argentina"= "arg"...."India"=Ïnd" and also the point to note is that the count of countries tend to differ too depending on what's in the next list..A macro will help ?

Any help would mean a lot. Thanks

1 REPLY 1
RichardinOz
Quartz | Level 8

You can use the cntlout= option to copy all existing formats to a SAS dataset.  This can be distributed for review or stored as a backup.  It can be exported to Excel for amendment and then imported back into SAS.  There are a lot of columns but the main ones to review are called start and end, the start and end values for a range covered by a single formatted value.  Additional rows can be entered if required.  The modified table can then be read back into proc format using cntlin=.  Make sure no-one has renamed any of the columns.

Proc format cntlin=work.formatlist ; quit ;

You can also create a cntlin table to add a new format into the library, from a lookup table in the database.  At a minimum you need to define s start column, a label column to hold the formatted value, and a fmtname column as the name of the format.  A HLO column is often useful to define how the format will handle out of range values.

Richard

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
  • 1 reply
  • 365 views
  • 4 likes
  • 2 in conversation