Hello ,
I have written this code and it says Syntax Error. I dont find anything wrong. Could someone review and let me know the issue?
proc format;
value $surg
'10021'-'10180', '11000'-'11057'
'11100'-'11312', '11313'-'11442'
'11443'-'11621', '11622'-'11772'= 1
other=0;
run;
Thanks so much
The output of a format is a character string. The values "1" and "0" need quotes.
If you want a numeric output, you will need to create an informat instead of a format.
Hello Astounding,
Thansk fo rth ereply. Even after I put the quotes I have a syntax error!!
812 proc format;
813 value $surgeries
814 '10021'-'10180', '11000'-'11057'
815 '11100'-'11312', '11313'-'11442'
-
22
76
ERROR 22-322: Syntax error, expecting one of the following: (, ',', =.
ERROR 76-322: Syntax error, statement will be ignored.
816 '11443'-'11621', '11622'-'11772'= "1"
817 other="0";
NOTE: The previous statement has been deleted.
818 run;
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 89.46k
OS Memory 23284.00k
Timestamp 11/11/2016 02:25:03 PM
Step Count 36 Switch Count 0
NOTE: The SAS System stopped processing this step because of errors.
Hello Astounding,
It worked. I was misssing a comma between those format pairs.
Just curious that it worked fine even without putting quotes for The values "1" and "0" . Do i need to know anything regarding this?
Thanks
Just think of it in the right way ... a format is always a set of characters, because it is a way to express the actual value of a variable. If you want a numeric result, use an INVALUE statement instead of a VALUE statement, and you can reate an informat.
Glad you got it to work.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.