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
SAS Super FREQ
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....

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!

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.

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
  • 5 replies
  • 847 views
  • 0 likes
  • 4 in conversation