Help using Base SAS procedures

Move Spaces to Low values

Reply
N/A
Posts: 0

Move Spaces to Low values

Hi,

My code has to read a IMS database and has to generate an extract file for that upon certain validation.

On which one of the field has low-values by default when there is no value to populate, in such case I have to replace them to spaces before I output to the extract file, other than that the actual value has to go for the extract.
I seek solution for my above requirement from experts.
Thanks in Advance,
N/A
Posts: 0

Re: Move Spaces to Low values

[pre]
%let LOW_VALUE = __________________ ; * fill in your low value ;
data outdata;
infile indata isam;
input var1 $ var2 ;
if var1 lt &LOW_VALUE then var1 = " ";
output;
run;
[/pre]

this sounds like it may be a homework assignment, as it is very basic SAS coding.
Have you read anything about how to program in SAS?
The online SAS Documentation is rather extensive, and fairly good/well written.
N/A
Posts: 0

Re: Move Spaces to Low values

As I said in different post that I haven't read any books on SAS and not trained I work with what exists already in the system.
I found the answer using RANK function, thank you for taking time to provide me a solution.
SAS Super FREQ
Posts: 8,743

Re: Move Spaces to Low values

Hi:
SAS does NOT have the same concept of HIGH-VALUES and LOW-VALUES as other languages like COBOL. For example, in this COBOL code snippet (from here: http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/apiref/exdqilecobol.htm
[pre]

*
* Initialize QCAPCMD options control block for CL processing
*
MOVE 0 TO COMMAND-PROCESS-TYPE.
MOVE "0" TO DBCS-DATA-HANDLING.
MOVE "0" TO PROMPTER-ACTION.
MOVE "0" TO COMMAND-STRING-SYNTAX.
MOVE SPACES TO MESSAGE-KEY.
MOVE LOW-VALUES TO RESERVED OF QCA-PCMD-CPOP0100.

[/pre]

This is how you initialize field values with COBOL -- essentially moving default values into the fields.
As I remember, HIGH-VALUES was all hex FF and LOW-Values was all 00. As a COBOL programmer,
it was easy to tell when you had "data" versus the "default" value because you could test for HIGH-VALUES
or LOW-VALUES, which would never come from the users because they were impossible to type into a screen.

COB2SAS is a SAS utility that we used to use to turn our COBOL copybooks into SAS INPUT statements, there's this note (in the documentation)
http://support.sas.com/techsup/technote/ts620.html
about how to test for HIGH/LOW values (if you are getting INVALID data when you try to read a COBOL created file with SAS):

[pre]

HIGH-VALUES or LOW-VALUES may be in your copybook. SAS doesn't have the concept of low or high values.
This should be easy to detect by looking in the hex dump in your SASLOG of the record being read.
If you do have high or low values in your data, one approach would be to read the field in as character
and test for '00'x and 'FF'x. If it's not, then use the INPUT function to convert it to the appropriate
numeric. Another approach would be to use the ? ? modifier on your INPUT statement
so that the 'INVALID DATA' messages aren't generated.

[/pre]

Are you using SAS/Access to IMS??? Not that it matters much. Tech Support or the documentation might be able to tell you whether there's another
option other than the test described above -- not that it's too hard, it would just be an IF statement.

cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 557 views
  • 0 likes
  • 2 in conversation