BookmarkSubscribeRSS Feed
deleted_user
Not applicable
hello everyone,

first of all: IT'S WORKING 🙂 great!!! thank you so much!
(a side-question: how can I post my code here in Courier and not in the Arial font? the code looks so poor in Arial)

I needed a macro because there are more than one table of this type in the project, but I mixed all solutions to one, the final one, this one:

/************** CODE BEGIN *********************/

proc SQL noprint;
select NAME into :toBON separated by ' ' from Merk where METHODE eq 'S%';
quit;

/* translate S% values into BON19 values */;
%macro S2BON19( strDataSet );
data &strDataSet;
modify &strDataSet;

array s
  • 8 &toBON;

    /* Checking method */
    do _i_=1 to dim( s );
    if not MISSING( s[_i_] ) then do;
    if 0 le s[_i_] le 10 then s[_i_]=1;
    else if 10 lt s[_i_] le 20 then s[_i_]=2;
    else if 20 lt s[_i_] le 30 then s[_i_]=3;
    else if 30 lt s[_i_] le 40 then s[_i_]=4;
    else if 40 lt s[_i_] le 50 then s[_i_]=5;
    else if 50 lt s[_i_] le 60 then s[_i_]=6;
    else if 60 lt s[_i_] le 70 then s[_i_]=7;
    else if 60 lt s[_i_] le 80 then s[_i_]=8;
    else if 80 lt s[_i_] then s[_i_]=9;
    end;
    end;

    replace;
    run;
    %mend;

    /********************* CODE END **********************/

    and best is: I even understand that code now 🙂

    thank you soooooo much, you saved my day 🙂

    Tom
  • SPR
    Quartz | Level 8 SPR
    Quartz | Level 8
    Hello Tom,

    "how can I post my code here in Courier...?"

    This is the answer:
    http://support.sas.com/forums/thread.jspa?messageID=27609毙

    Sincerely,
    SPR
    deleted_user
    Not applicable
    Hello SPR,

    thank you!

    so this is the final code:

    [pre]
    /* translate S% values into BON19 values */;
    %macro S2BON19( strDataSet );

    proc SQL noprint;
    select NAME into :toBON separated by ' ' from Merk where METHODE eq 'S%';
    quit;

    data &strDataSet;
    modify &strDataSet;

    array s
  • 8 &toBON;

    /* Checking method */
    do _i_=1 to dim( s );
    if not MISSING( s[_i_] ) then do;
    if 0 le s[_i_] le 10 then s[_i_]=1;
    else if 10 lt s[_i_] le 20 then s[_i_]=2;
    else if 20 lt s[_i_] le 30 then s[_i_]=3;
    else if 30 lt s[_i_] le 40 then s[_i_]=4;
    else if 40 lt s[_i_] le 50 then s[_i_]=5;
    else if 50 lt s[_i_] le 60 then s[_i_]=6;
    else if 60 lt s[_i_] le 70 then s[_i_]=7;
    else if 60 lt s[_i_] le 80 then s[_i_]=8;
    else if 80 lt s[_i_] then s[_i_]=9;
    end;
    end;

    replace;
    run;
    %mend;
    [/pre]

    thanks to all,
    Tom
  • What is Bayesian Analysis?

    Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

    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
    • 32 replies
    • 3360 views
    • 0 likes
    • 6 in conversation