BookmarkSubscribeRSS Feed
tom16
Calcite | Level 5
Hi,

how can I permanently change variables values by using proc format...I want to create excle file.....but when I am trying to export file with formats it agains taking original variables values rathere then formats values.....

data temp.sample_final2;
set sample_final;
format govtn gov. age age.;
run;

Thanks....
5 REPLIES 5
Cynthia_sas
Diamond | Level 26
Hi:
You don't show the formats for GOV. or AGE. formats. Without seeing how you are trying to format the numbers, it is impossible to understand what you mean when you say that Excel takes "original variable values rather than format values".

You also do not show the method by which you are getting output into Excel -- LIBNAME engine?? PROC EXPORT?? ODS CSV?? ODS HTML?? ODS TAGSETS.EXCELXP??

All of this information is essential to understanding the problem and making constructive suggestions.

cynthia
tom16
Calcite | Level 5
Hi here is information..

proc format;
value gov 0 = 'Confirming'
1='notconforming'
;
value $age '1'='25-49'
'2'='50-69'
' 3'=' 70+'
;
data A;
set B;
format gover gov. age age.;
run;

Now I am using proc export to export data set A in Excel format... I want format values in my exported excel sheet. But I got same variables values which are in data set B, how can I get this format values in my excel sheet....I will appreciate your help..
Reeza
Super User
Check your log, you should be getting an error, because the age format is a character format and needs to be applied as $age.

try using ods html output as follows and see if it works..

ods html file='c:/test.xls';

proc print data=a label;
run;

ods html close;
Ksharp
Super User
How about;
[pre]
proc format;
value gov 0 = 'Confirming'
1='notconforming'
;
value $age '1'='25-49'
'2'='50-69'
' 3'=' 70+'
;
data A;
set B;
want_gover=put(gov,gov.);
want_age=put(age,$age.);

run;
tom16
Calcite | Level 5
Thank you very much for your reply again....it works very nicelly....

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1561 views
  • 0 likes
  • 4 in conversation