BookmarkSubscribeRSS Feed
Kayla_Tan222
Calcite | Level 5

Hi all, I'm currently convert the code in visualfoxpro to sas.

 

Is there any difference between isblank and isnull function in vfox?

if I write the code in sas like this below, is this correct?

 

 

VFOX CODE


use "D:\Fire\claim\Fire_clm_201903_addratecde.dbf"
scan for (not inli(allt(ratecde),"1000","COIN") and not isbl(ratecde) and not isnull(ratecde))
Do case
case inli(rsktyp,"FCL","FCZ","FLP")
repl cov_type with "Conloss"


case inli(rsktyp,"FAZ","FDA","FIA")
repl cov_type with "IAR"


case inli(left(allt(ratecde),4),"4006","4008")
repl cov_type with "HH"


case inli(left(allt(ratecde),4),"4001","4005")
repl cov_type with "HO"


otherwise


DO casecase inli(left(allt(ratecde),2),"10")
repl cov_type with "MD1"


case inli(left(allt(ratecde),2),"11")
repl cov_type with "MD2"


case inli(left(allt(ratecde),2),"12")
repl cov_type with "MD3"


case inli(left(allt(ratecde),2),"14")
repl cov_type with "MD4"


case inli(left(allt(ratecde),2),"29")
repl cov_type with "MD5"


otherwise


repl cov_type with "MD6"


endcase
endcase
endscan

 

 

 

 

MY Code in sas

 

if ratecde^='1000' and ratecde^='coin' and ratecde^='' then do;

 

if rsktyp in ('FCL','FCZ','FLP') then

cov_type='Conloss';

else if rsktyp in ('FAZ','FDA','FIA') then

cov_type='IAR';

else if test1 in ('4006','4008') then

cov_type='HH';

else if test1 in ('4001','4005') then

cov_type='HO';

 

 

 

else if test2=10 then

cov_type='MD1';

else if test2=11 then

cov_type='MD2';

else if test2=12 then

cov_type='MD3';

else if test2=14 then

cov_type='MD4';

else if test2=29 then

cov_type='MD5';

 

else

cov_type='MD6';

end;

 

3 REPLIES 3
ScottBass
Rhodochrosite | Level 12

I don't know vfox so don't know the intricacies of isblank and isnull.

 

Re: your code:  I like the missing() function, as it "does the right thing" whether the variable is character or numeric:

 

data test;
   chr1='';
   chr2=' ';
   chr3='  ';
   chr4='foo';
   num1=.;
   num2=.a;
   num3=.z;
   num4=123;
   ismiss_chr1=missing(chr1);
   ismiss_chr2=missing(chr2);
   ismiss_chr3=missing(chr3);
   ismiss_chr4=missing(chr4);
   ismiss_num1=missing(num1);
   ismiss_num2=missing(num2);
   ismiss_num3=missing(num3);
   ismiss_num4=missing(num4);
run;

Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
ChrisNZ
Tourmaline | Level 20

Wouldn't this be closer?

  if strip(RATECDE) not in('1000', 'COIN', ' ') then do;
    select;
      when(RSKTYP in ('FCL','FCZ','FLP')     ) COV_TYPE='Conloss';
      when(RSKTYP in ('FAZ','FDA','FIA')     ) COV_TYPE='IAR';
      when(strip(RATECDE) in: ('4006','4008')) COV_TYPE='HH';
      when(strip(RATECDE) in: ('4001','4005')) COV_TYPE='HO';
      when(strip(RATECDE) =: '10'            ) COV_TYPE='MD1';
      when(strip(RATECDE) =: '11'            ) COV_TYPE='MD2';
      when(strip(RATECDE) =: '12'            ) COV_TYPE='MD3';
      when(strip(RATECDE) =: '14'            ) COV_TYPE='MD4';
      when(strip(RATECDE) =: '29'            ) COV_TYPE='MD5';
      otherwise                                COV_TYPE='MD6';
    end;
  end;

 

Tom
Super User Tom
Super User

SAS stores character variables as fixed length strings that are padded with spaces.  So SAS cannot tell the difference between a variable that is all blanks and a "null" or "missing" value.  

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1309 views
  • 1 like
  • 4 in conversation