How do you create a (proc) format for a variable having mixed values (character and numeric) like ME2 and SE2 ? Is it possible? Or is there any other way?
Numbers are characters.
Are ME2/SE2 variables or values your having issues with? Please explain in detail.
If you variable JOBCODE has values like 'ME2' then you have a character variable. You will need to use a character format.
proc format;
value $jobcode
'ME2'='Must Enter Twice'
;
run;
....
format jobcode $jobcode. ;
....
That should work.
Close, but probably not the way you want. YOU should always test your code.
To test a format, test all values AND some values that aren't in your list.
proc format;
value $Jobf
'TA2'='MANAGER'
'ME2'='ASSISTANT'
'ME1'='TECHNICAL WRITER'
'FA3'='SENIOR TECHNICAL WRITER'
'TA3'='ASST MANAGER'
'ME3'='ASSISTANT ASST'
'SCP'='TIME PASS';
RUN;
data test;
input orig $5.;
want=put("TA2", $jobf.);
cards;
TA2
ME2
ME1
FA3
TA3
ME3
SCP
XXX
YYY
AAA
TB24
TA24
ME23
;
run;
proc print data=test;run;
Try it...
@SamuelRajKandru wrote:
Below is the screenshot of the output. I think something's wrong?
Yes, that was the point of this little exercise, though not as bad as your output.
Check the log to make sure no errors occurred.
Sorry, typo
Want=put(orig, $jobf.);
Okay, corrected the code and submitted it. There weren't any errors or warnings in the log.
So, are the results what you want? If so, your done.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.