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-2024.png

    Available on demand!

    Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

     

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