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
  • sas-innovate-2024.png

    Don't miss out on SAS Innovate - Register now for the FREE Livestream!

    Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

     

    Register now!

    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.

    Click image to register for webinarClick image to register for webinar

    Classroom Training Available!

    Select SAS Training centers are offering in-person courses. View upcoming courses for:

    View all other training opportunities.

    Discussion stats
    • 32 replies
    • 1475 views
    • 0 likes
    • 6 in conversation