BookmarkSubscribeRSS Feed
diva_di_dati
Calcite | Level 5


one do one end .....is there something else needed to  close this do block?

data da;

      merge output.da_med (in=in1) output.da_rx (in=in2); *merge the ones and zeroes produced by CDPS and MRX above;

      by recipno;

      if _n_ = 1 then set weight_dac; *insert the weights on every record;

    aidcat = 'DA';

      %bridge; *run the bridge code macro;

      *set up arrays to facilitate multiplication of a large list of variables;

      array ind

  • &
  • list. CCARVH CCARM CCNSH CPULVH CPULH CGIH CMETH CHIVM CINFM CHEMEH ;

          array fac

  • &
  • factors. CCARVH_fac CCARM_fac CCNSH_fac CPULVH_fac CPULH_fac CGIH_fac CMETH_fac CHIVM_fac

                                           CINFM_fac CHEMEH_fac;

          risk_score = intercept_fac; *intercept must be added to every risk score;

          do i = 1 to dim(fac);

                *cycle through all the 1/0s and factors, multiply them together, and add them to the risk score field;

                risk_score = risk_score + ind * fac;

          end;

          drop intercept_fac &factors. i CCARVH_fac CCARM_fac CCNSH_fac CPULVH_fac CPULH_fac CGIH_fac CMETH_fac CHIVM_fac

                 CINFM_fac CHEMEH_fac aid;

    run;

    Thx

    15 REPLIES 15
    PaigeMiller
    Diamond | Level 26

    We can't provide an answer, you haven't shown us what is in %bridge

    --
    Paige Miller
    diva_di_dati
    Calcite | Level 5

    Here is the full code-thank you for your efforts...

    PaigeMiller
    Diamond | Level 26

    Great, so somewhere in %bridge, there is an unclosed do block.

    Your task is then to go through %bridge and figure out where this unclosed do block is.

    --
    Paige Miller
    falguni_mathther
    Calcite | Level 5

    Agreed with PaigeMiller, I think in the last line of Bridge some problem is there.

    diva_di_dati
    Calcite | Level 5

    ok, that is what I am asking about...I can't find it....I think I have matched up all of the do and ends.....am I matching up the wrong things......I thought a do block started with 'do' and ended with 'end'

    art297
    Opal | Level 21

    What about the code for the other macro you call?  You didn't include it?  Also, when you call a macro, the line shouldn't end with a semicolon.

    Yes, your understanding is correct.

    Reeza
    Super User

    If you're absolutely stuck and can't find the end to match a do, start numbering them.

    do start=1 to 20; /*1*/

         some code...;

         do test=1 to 50; /*2*/

         some more code...;

         end ;/*2*/

    end;/*1*/

    ChrisHemedinger
    Community Manager

    If you have SAS Enterprise Guide 4.3 or 5.1, you might try running this (and the macros that it references) through the code formatter:

    http://blogs.sas.com/content/sasdummy/2010/12/23/the-sas-code-formatter-more-than-a-pretty-face/

    Chris

    It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
    Tom
    Super User Tom
    Super User

    The lines in that file are way too long for human consumption.

    And SAS might even have trouble with them depending on the version you are using and the settings.

    I suspect that some lines are being truncated.

    Especially because the %BRIDGE macro has a couple of END statements out past column 165!!!!

    PaigeMiller
    Diamond | Level 26

    I agree with Tom

    While the problem may or may not be in %Bridge, the way things are written, in one long line "way too long for human consumption", the appearance of the code hinders debugging and understanding. This code ought to be one command per line, and properly indented. My eyes are not used to looking at code written like this, it hurts my brain to look at code written like this, and so even though I was being unhelpful, I didn't even try to see if I could find a problem in this code.

    --
    Paige Miller
    ballardw
    Super User

    Run the code with OPTIONS MPRINT to see if there's anothe DO block in any of your macros.

    BTW, becareful habitually ending references to macro variables with a period when you aren't actually concatenating something.

    ballardw
    Super User

    I ran a piece of code using 1 for the value of all of the  variables and only the BRIDGE macro as shown in your attachment and did not get any message about unclosed do loop (see code at bottom).

    At this point point I would start with the offending datastep and comment out all the statements and the add them back in one at a time (with loops the start and end count as one statement for this process - but do run with the stuff inside the loops commented out).

    I would also make sure the other macros CDPS and MRX do not contain definitions of or modify the BRIDGE macro.

     

    data junk;

    Retain &list &factors 1;

    aidcat = 'DA';

    %bridge

    run;

    sas-innovate-2024.png

    Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

    Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

     

    Register now!

    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.

    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
    • 15 replies
    • 5368 views
    • 4 likes
    • 9 in conversation