Help using Base SAS procedures

Proc format

Reply
Occasional Contributor
Posts: 13

Proc format

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....
SAS Super FREQ
Posts: 8,742

Re: Proc format

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
Occasional Contributor
Posts: 13

Re: Proc format

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..
Super User
Posts: 17,784

Re: Proc format

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;
Super User
Posts: 9,671

Re: Proc format

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;
Occasional Contributor
Posts: 13

Re: Proc format

Thank you very much for your reply again....it works very nicelly....
Ask a Question
Discussion stats
  • 5 replies
  • 170 views
  • 0 likes
  • 4 in conversation