BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rpg163
Calcite | Level 5

Hi, I am trying to calculate the standard deviation of follow variables:

data sample;

    set EVA_Inv.sample_v1;

        array a CFO_ta Sales_Ta Inv_Total;

        array b std_CFO std_Sales std_Inv;       

        do i=1 to dim(a);

            b(i)=std(a(i),lag(a(i)),lag2(a(i)));

    end;

     std_cfo1=std(CFO_ta,lag(CFO_ta),lag2(CFO_ta));

run;

well, it seems "std_cfo1" get result, yet all b(i) return missing value.

What's the problem?

Anyone can please tell me? THX!

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

I tested it. No problem.

data sample;
    set sashelp.class;
        array a{*} age weight height;
        array b{*} _age _weight _height;       
        do i=1 to dim(a);
            b{i}=std(a{i},lag(a{i}),lag2(a{i}));
    end;
run;



Ksharp

View solution in original post

2 REPLIES 2
Ksharp
Super User

I tested it. No problem.

data sample;
    set sashelp.class;
        array a{*} age weight height;
        array b{*} _age _weight _height;       
        do i=1 to dim(a);
            b{i}=std(a{i},lag(a{i}),lag2(a{i}));
    end;
run;



Ksharp

rpg163
Calcite | Level 5

Yes, I test your code,you are right!

Well, I just check the code again and find I missed sth.

now I get it.

THX!

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!

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
  • 2 replies
  • 698 views
  • 0 likes
  • 2 in conversation