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.
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.
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.