DATA Step, Macro, Functions and more

Update Existing Format Value

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

Update Existing Format Value

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


Accepted Solutions
Solution
‎03-17-2017 12:51 PM
Super User
Posts: 7,827

Re: Update Existing Format Value

[ Edited ]

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;

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Super User
Posts: 7,976

Re: Update Existing Format Value

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.

Solution
‎03-17-2017 12:51 PM
Super User
Posts: 7,827

Re: Update Existing Format Value

[ Edited ]

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;

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 10

Re: Update Existing Format Value

Posted in reply to KurtBremser
Thank you !! KurtBresmer Smiley Happy 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;
Super User
Posts: 7,827

Re: Update Existing Format Value

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; 
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 379 views
  • 0 likes
  • 3 in conversation