Good evening community.
I have a program on 9.3 (AIX) that generates the following value for COBOL 4=▒ when applying the IB4 format. At value date 20200903.
The same program in SAS 9.4 (LINUX) generates the following value 4=Ç
What format can I apply to obtain the same value (4=▒)?.
Thank.
I cannot make sense of what your question is. What is COBOL in this case? Are you talking about the programming language COBOL? Or is that the name of some character variable in your dataset?
You seem to have pasted some types on non-ASCII characters into your question. Where did you get those characters? Are they in a file on your computer? Can you examine the file with a program that can display the actual hexadecimal codes for the characters? For example when I copy that character you posted that looks like a capital letter C with a tail into a SAS session running with LATIN1 encoding it looks like the character 'C7'x.
1283 data _null_; 1284 x = ' 4=Ç' ; 1285 put x= $quote. / x= $hex.; 1286 run; x=" 4=Ç" x=20343DC7
And what do these character strings have to do with the number 20,200,903 that you also showed?
The POWER architecture is big-endian, Intel is little-endian. The IB format stores numbers in the native format of the processor.
So it looks like you are using UTF-8 encoding in your SAS session because it used three bytes to display that character.
But that really doesn't help much with understanding what your actual question is.
Did the original programmer really type that strange character into the CODE?
Or are just not explaining that you are trying to read (or perhaps write) from some file instead?
If you are reading from a file then you can use the $HEX format to display the codes for a line of the file.
data _null_;
infile 'myfile.dat' obs=3 truncover;
input string $char100.;
put string $hex.;
run;
Or use the LIST statement and it will display the hex codes for any line that includes no printable characters.
data _null_;
infile 'myfile.dat' obs=3 truncover;
input ;
list;
run;
The number 20,200,903 you mentioned is NOT a date. SAS dates are stored as the number of days since 1960 so a number that large would be in the year 57,267 if treated as a date value.
But if you want to convert that number to a four byte integer you could use PIB4. format or the S370FPIB4. format. Depending on whether you want little endian or big endian numbers. You can reverse the process using the same named informats.
1860 data test; 1861 number=20200903; 1862 str1=put(number,pib4.); 1863 str2=put(number,S370Fpib4.); 1864 put str1=$hex. / str2=$hex.; 1865 number1 = input(str1,pib4.); 1866 number2 = input(str2,s370fpib4.); 1867 put (number:) (=comma15./); 1868 run; str1=C73D3401 str2=01343DC7 number=20,200,903 number1=20,200,903 number2=20,200,903
I don't really understand what you're asking for but one comment: How a value prints will depend on your environment. If you want to verify if the actual value is the same or different when running a process in different environment then look at the HEX or Binary representation of the value and not how it prints. SAS provides formats for printing values in their Hex or Binary representation.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.