Help using Base SAS procedures

When does format statement take effect

Posts: 0

When does format statement take effect

I heve a proc sql to make a sasdataset called result.
The dataset contains a variable amount wich has a format of commax13.2

I want to sort the dataset and give the variable amount an format of z11.
proc sort data=userdata.result;
by xxx;
FORMAT amount z11. ;
But the format stays commax13.2

I also use a proc export:
PROC EXPORT DATA=userdata.result
OUTFILE = 'Q:\bla\bla\xx.txt'
DBMS = dlm
FORMAT amount z11. ;
But the format stays commax13.2

So the question is why doesn't it work, does the format statement only have effect when creating a new dataset?
Super User
Posts: 5,437

Re: When does format statement take effect

Posted in reply to deleted_user
I did a small test on SASHELP.class, and it works for me:

proc copy in=sashelp out=work;
select class;

proc sort data=class;
by age;
format age z11.;

proc print;

Obs Name Sex Age Height Weight
1 Joyce F 00000000011 51.3 50.5
2 Thomas M 00000000011 57.5 85.0
3 James M 00000000012 57.3 83.0
4 Jane F 00000000012 59.8 84.5

Please attach full log and partial output from your example.
Data never sleeps
Posts: 0

Re: When does format statement take effect

Thanks for your anwser, i did some further checking

The format didn't work on the proc sort because the dataset was already sorted in the right way, so no sorting was done and no reformating.

why the format didn't work with proc export i'm still checking.
Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation