BookmarkSubscribeRSS Feed
Filipvdr
Pyrite | Level 9
Hello

I have data like DO1;DO3;DO4-DO10;DO15;DO17;
So in total my number would be 11 (1,3,4,5,6,7,8,9,10,15,17)

Currently i have this:

Number = countc(DataField,';') + 1;

but I need the objects between DO4 and D010 as well.. any help?
1 REPLY 1
data_null__
Jade | Level 19
Much depends on what your ultimate goal is. I personally don't like to think too hard. I see that that DATAFIELD looks like a SAS Variable List that can be used in a array statement. If I let SAS create an ARRAY with the list I can use DIM to determine the number of elements.

[pre]
431 data _null_;
432 dataField='DO1;DO3;DO4-DO10;DO15;DO17;';
433 call symputX('dataField',translate(datafield,' ',';'));
434 run;



435 %put NOTE: DATAFIELD=&datafield;
NOTE: DATAFIELD=DO1 DO3 DO4-DO10 DO15 DO17
436 data _null_;
437 array d
  • &datafield;
    438 call symputX('dim',dim(d));
    439 run;

    440 %put NOTE: DIM=&dim;
    NOTE: DIM=11
    [/pre]


    This concept can be extended to any "Variable List" using PROC TRANSPOSE.
  • SAS Innovate 2025: Call for Content

    Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

    Submit your idea!

    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
    • 1 reply
    • 717 views
    • 0 likes
    • 2 in conversation