BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sanket
Fluorite | Level 6

Hi All,

 

I want to update existing format.

 

i tried

 

proc format library = work.formats

cntlout = cntlout;

run;

 

Now i want to update value for the existing format.

 

Format name :- FMT1

 

Old Value - ' OLDNAME'  to New Value - ' NEWNAME'

 

so next time it should pickup NEWNAME so how to update existing format FMT1 Value ?

 

Please advise.

 

Thank you,

Sanket

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

@Sanket wrote:

Hi All,

 

I want to update existing format.

 

i tried

 

proc format library = work.formats

cntlout = cntlout;

run;

 

Now i want to update value for the existing format.

 

Format name :- FMT1

 

Old Value - ' OLDNAME'  to New Value - ' NEWNAME'

 

so next time it should pickup NEWNAME so how to update existing format FMT1 Value ?

 

Please advise.

 

Thank you,

Sanket


You created a new dataset that describes all the formats in WORK when you ran

proc format library = work.formats cntlout = cntlout;
run;

Now you can look in that dataset (WORK.CNTLOUT) and replace the value you want to have replaced.

After that, use the dataset as input for proc format:

proc format library = work.formats cntlin = cntlout;
run;

 

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Post test datas in the form of a datastep if you want exact answers.  This is just the theory - use cntlout to get a dataset as you have done, updated that dataset as you want, then cntlin in proc format to read the dataset back in.

Kurt_Bremser
Super User

@Sanket wrote:

Hi All,

 

I want to update existing format.

 

i tried

 

proc format library = work.formats

cntlout = cntlout;

run;

 

Now i want to update value for the existing format.

 

Format name :- FMT1

 

Old Value - ' OLDNAME'  to New Value - ' NEWNAME'

 

so next time it should pickup NEWNAME so how to update existing format FMT1 Value ?

 

Please advise.

 

Thank you,

Sanket


You created a new dataset that describes all the formats in WORK when you ran

proc format library = work.formats cntlout = cntlout;
run;

Now you can look in that dataset (WORK.CNTLOUT) and replace the value you want to have replaced.

After that, use the dataset as input for proc format:

proc format library = work.formats cntlin = cntlout;
run;

 

Sanket
Fluorite | Level 6
Thank you !! KurtBresmer 🙂 It worked fine on Friday I tried with an below example. proc format; value $id '1'='Mary' '2'='Tom' '3'='Joe' ; run; options fmtsearch=(work); proc format fmtlib library=work.formats; select $id; run; quit; proc format library = work.formats cntlout = cntlout; select $id; run; proc sql; update cntlout set LABEL='Kim' where label='Joe'; quit; Now you can look in that dataset (WORK.CNTLOUT) and replace the value you want to have replaced. After that, use the dataset as input for proc format:; proc format library = work.formats cntlin = cntlout; select $id; run; proc format library = work.formats cntlout = cntlout; select $id; run;
Kurt_Bremser
Super User

Use the "little running man" icon in the top of your "Post" or "Reply" window to post SAS code. This preserves the formatting and even gives you enhanced-editor-like coloring:

proc format;
value $id
  '1'='Mary'
  '2'='Tom'
  '3'='Joe'
;
run;

options fmtsearch=(work);

proc format fmtlib library=work.formats;
select $id;
run;

quit; * not necessary;

proc format library = work.formats cntlout = cntlout;
select $id;
run;

proc sql;
update cntlout
set LABEL='Kim'
where label='Joe';
quit;

proc format library = work.formats cntlin = cntlout;
select $id;
run;

proc format library = work.formats cntlout = cntlout;
select $id;
run; 

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
  • 4 replies
  • 5786 views
  • 1 like
  • 3 in conversation