libname deepak 'C:\SAS Files';
proc format;
invalue convert 'A+' = 100
'A' = 96
'A-' = 92
'B+' = 88
'B' = 84
'B-' = 80
'C+' = 76
'C' = 72
'F' = 65;
data deepak.grades;
input ID $3. Grade convert.;
*format Grade convert. ;
datalines;
001 A-
002 B+
003 F
004 C+
005 A
;
proc print data = deepak.grades;
run;
I get the following output
Obs ID Grade
1 001 .
2 002 .
3 003 .
4 004 .
5 005 .
I don’t understand why Grade shows up as a missing value.
Everything seems fine, including ID $3.
Now, in case I use ID : $3. Or use column input, I get the
desired output.
Kindly help
Deepak
Answers were Sorted based on User's Feedback
Answer / kondal
i hope this code will work.
data grades;
input ID $3. Grade : convert.;
datalines;
001 A-
002 B+
003 F
004 C+
005 A
;
proc print data =grades;
run;
Is This Answer Correct ? | 4 Yes | 1 No |
Answer / deepak
Thanks Kondal,
But why does it not work? If u see there, ID has only 3
columns, and technically it must work without a colon (ID :
$3.). I get a perfct output with a semicolon, but without it
I dont.
Is this something specific about user defined Informats?
Appreciate any help
Deepak
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / amaresh
proc format;
invalue convert 'A+' = 100
'A' = 96
'A-' = 92
'B+' = 88
'B' = 84
'B-' = 80
'C+' = 76
'C' = 72
'F' = 65;
run;
data grades;
input ID @5 Grade convert.;
datalines;
001 A-
002 B+
003 F
004 C+
005 A
;
run;
Is This Answer Correct ? | 1 Yes | 1 No |
Hi,
you must assign position of Grade variable.you gave a length of id is $3. so you must gave a proper position to Grade variable otherwise it will show the missing.
proc format;
invalue convert 'A-' = 100
'A' = 96
'B+' = 88
'C+' = 76
'F' = 65
;
run;
data deepak;
input ID $3. @5 Grade convert.;
datalines;
001 A-
002 B+
003 F
004 C+
005 A
;
run;
proc print data = deepak;
run;
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / virat samratt
proc format;
invalue $convert 'A+' = 100
'A' = 96
'A-' = 92
'B+' = 88
'B' = 84
'B-' = 80
'C+' = 76
'C' = 72
'F' = 65;
data grades;
input ID $3. Grade$ convert.;
datalines;
001 A-
002 B+
003 F
004 C+
005 A
;
add $ before format name in proc format statement
then you will get
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ramakrishna
proc format;
invalue convert 'A+' = 100
'A' = 96
'A-' = 92
'B+' = 88
'B' = 84
'B-' = 80
'C+' = 76
'C' = 72
'F' = 65;
run;
data grades;
input ID $3. Grade $ convert.;
*format Grade convert. ;
datalines;
001 A-
002 B+
003 F
004 C+
005 A
;
proc print data = grades;
run;
Is This Answer Correct ? | 0 Yes | 2 No |
What is the order of evaluation of the comparison && logical && relational operators:?
what are the best practices to process the large data sets in sas programming? : Sas-administrator
How would you combine 3 or more tables with different structures?
how will you location sas platform applications available from web browser? : Sas-bi
What is SAS informats?
Why and when do you use proc sql?
What are the differences between proc means and proc summary?
what does .. meant in sas macros
How to get top scorer student from a class-table having different sections A,B, C & D? Each section having same number of students.
how to read character value without using substr function in sas ?
What Proc glm does?
Can we use where and having clauses in a single SAS program. ex: proc sql; select a,b,c from test where state in 'KA' and having <some condition>. Is the above program run correctly, if not why ?