Your example where the format works in the put() function, but not in the immediately following viewtable is IMO convincing enough for a call to SAS TS.
I need to contact my SAS Admins for a fix to this problem.
Today my environment was changed from SAS EG 5.1(GRID SAS93) to SAS EG 7.1(GRID SAS94). I tried running the same code in my new environment. Suprisingly it gave the output I'm looking. Even I tried running the same code in different environments.
Code:
proc format ;
value $se 'M'='Male'
'F'='Female';
run;
data ONE;
set sashelp.class;
format sex $se. ;
gender=put(sex,$se.);
run;
Results:
SAS EG 5.1 and Grid on SAS 9.3
SAS EG 5.1 and Grid on SAS 9.4
SAS EG 7.1 and Grid on SAS 9.3
SAS EG 7.1 and Grid on SAS 9.4
Ohh! This is something interesting to find the reason for this.
If you are trying to mix using 9.3 and 9.4 on the same sets of files you will have issues with format catalogs. In general SAS dataset will work ok across versions (on similar hardware), but format catalogs are version specific. So if you create a format catalog using SAS 9.4 and then tried to read it using SAS 9.3 it would not recognize the format catalog and hence not find your user defined format.
Hi Tom,
I'm sure I didn't mix 9.3 and 9.4. I didn't have 9.4 earlier. I got it today only.
I would like to make some summary of posts upto now, with some highlights:
1) RMTWORK is a remote directory on a server.
2) Running code: libname rmtwork list; printed next notes:
Libref= RMTWORK
Access= TEMP
Physical Name= /work/dev_work/SAS_work266802C0002A_p1sasgrid03
That means it is a temporary library and it is canceled at exit of SAS session.
3) In your dataset sex is defined as $1 - it is one character only.
First character of Female if F, first chracter of MALE is M;
That might explain why you see one/first character only;
4) Because RMTWORK is temporary library, you have to recreate the format each time you start a new session.
Beyond you may need run FMTSEARCH option, like:
options fmtsearch=RMTWORK;
and as FEMALE is 6 characters long, use $SEX6. format.
All in all, here is your code to run with slight changes:
proc format library=RMTWORK;
value $sex
'M'='Male'
'F'='Female'
;
Run;
options fmtsearch=(RMTWORK);
data RMTWORK.one;
length gender sex $6; /* run with and without sex variable in this line */
set sashelp.class;
format sex $sex6.
gender=put(sex,$sex6.);
run;
PAY ATTENTION: SEX. and $SEX. are different formats.
In case you still get SEX column displayed one character only you should call SAS technical support.
proc format library=RMTWORK;
value $sex
'M'='Male'
'F'='Female'
;
Run;
options fmtsearch=(RMTWORK);
data RMTWORK.one;
length gender sex $6;
set sashelp.class;
format sex $sex6. ;
gender=put(sex,$sex6.);
run;
Since the newer EG works OK, this might very well be a known bug where the fix is either in a hotfix for 5.1 (that you have not had installed by your admins) or was only incorporated in later EG versions.
Just to make sure, you could go browsing through the fixes for 5.1.
SAS Technical support says :
Hi Kiran,
You are running in a grid enabled environment which kicks off multiple workspace sessions
so you will need to define formats in the code that is being executed so that
the format will be known in that workspace server execution.
Regards,
Bill
Here I don't understand want he want me to do.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.