hello dear SAS experts,
I typed the following Code to define a numeric Format out of a character one:
/* Monatsformate für Erfolgsplan */ data erfgpln; length start $8 label 8; input start label; datalines; 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 JanMoy 21 FebMoy 22 MarMoy 23 AprMoy 24 MaiMoy 25 JunMoy 26 JulMoy 27 AugMoy 28 SepMoy 29 OctMoy 30 NovMoy 31 DecMoy 32 Jahr 33 ; run; data erfgplnf; set erfgpln end=last; retain fmtname 'Erfgplnf' type 'n'; output; run; proc format cntlin=erfgplnf fmtlib;run;
I got the following error message:
63 proc format cntlin=erfgplnf fmtlib; ERROR: For format ERFGPLNF, this range is repeated, or values overlap: .-..
How can I fix this?
Regards
PY
What does this phrase mean?
define a numeric Format out of a character one
Your start values have character strings "JanMoy" etc. So to convert that into a format you would need a character format not a numeric format.
Is your goal to create an INFORMAT instead of a FORMAT?
In that case use J as the TYPE.
Then you could use the new INFORMAT with an INPUT statement or INPUT() function call.
number = input('JanMoy',erfgpln.);
What does this phrase mean?
define a numeric Format out of a character one
Your start values have character strings "JanMoy" etc. So to convert that into a format you would need a character format not a numeric format.
Is your goal to create an INFORMAT instead of a FORMAT?
In that case use J as the TYPE.
Then you could use the new INFORMAT with an INPUT statement or INPUT() function call.
number = input('JanMoy',erfgpln.);
thanks, but I still can't use this.
Goal: I want a Format or informat to turn a character variable into a numeric one.
I simplified the first dataset and typed:
/* Monatsformate für Erfolgsplan */ data erfgpln; length start $2 label 3; input start label; datalines; A 1 B 2 C 3 D 4 E 5 F 6 G 7 H 8 I 9 J 10 K 11 L 12 M 21 N 22 O 23 P 24 Q 25 R 26 S 27 T 28 U 29 V 30 W 31 X 32 Y 33 ; run; data erfgplnf; set erfgpln end=last; retain fmtname 'Erfgplnf' type 'f'; output; run; proc format cntlin=erfgplnf fmtlib; run;
I get the following Display in the Formats:
---------------------------------------------------------------------------- | FORMAT NAME: ERFGPLNF LENGTH: 2 NUMBER OF VALUES: 1 | | MIN LENGTH: 1 MAX LENGTH: 40 DEFAULT LENGTH: 2 FUZZ: STD | |--------------------------------------------------------------------------| |START |END |LABEL (VER. V7|V8 19MAR2021:17:30:29)| |----------------+----------------+----------------------------------------| | .| .|33 | ----------------------------------------------------------------------------
which doesn't help to operate what I want.
What has to be modified?
I also typed :
data erfgplnf; set erfgpln end=last; retain fmtname 'Erfgplnf' type 'J'; output; run; proc format cntlin=erfgplnf fmtlib; run;
same result
Note that formats convert values to text. Informats convert text to values.
Numeric formats work on numeric values. Character formats work on character values. Numeric informats create numeric values. Character informats create character values.
To convert text to numbers you need a numeric informat.
Your original data is fine for defining a numeric INFORMAT, just use 'J' as the TYPE.
789 data erfgplnf; 790 set erfgpln end=last; 791 retain fmtname 'Erfgplnf' type 'J'; 792 run; NOTE: There were 25 observations read from the data set WORK.ERFGPLN. NOTE: The data set WORK.ERFGPLNF has 25 observations and 4 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 793 794 proc format cntlin=erfgplnf fmtlib; NOTE: Informat $ERFGPLNF has been output. 794 ! run; NOTE: PROCEDURE FORMAT used (Total process time): real time 0.13 seconds cpu time 0.03 seconds
eza,
thank you very much for your help.
I posted a longer topic to explain my concern:
https://communities.sas.com/t5/New-SAS-User/Pb-when-I-use-an-informat-I-defined/td-p/727822
I hope this will clear the problem.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.