BookmarkSubscribeRSS Feed
malakaext
Calcite | Level 5

Hi can someone please help me correct the error Im getting in the following code. Data set attached. thanks.

I AM USING SAS 9.0

5 REPLIES 5
Reeza
Super User

Whats the error? What are you trying to do that isn't working?

malakaext
Calcite | Level 5

sorry forgot to attach the code:

data test;

    infile "F:\data\wvar.csv"  DSD MISSOVER;

      input  residuals;

run;

data test1;

set test;

sig = 0;

_n_ =1;

do

call symput('res',residuals);

y = symput('res');

_n_= _n_ +1;

sig2 = 0.0000624 +  0.1438*y*y +  0.634*sig*sig;

sig = sqrt(sig2);

end;

PROC EXPORT DATA=test1

            OUTFILE="F:\data\residuals.csv"

            DBMS=csv REPLACE;

RUN;

run;

Cynthia_sas
SAS Super FREQ

Hi:

  Can you explain what portion of your code is related to SAS/GRAPH or ODS GRAPHICS? This code is probably better posted in either the SAS Procedures forum or the Data Step and Macro Language forum. Since I do not see ANY graph procedures in your code, I don't understand why your posting is here.

  Also, many folks do not have SAS 9.0 to test with. For help with older versions of SAS, you may want to work with SAS Tech Support. You also may want to look at the syntax for CALL SYMPUT (which is something that the folks in the Macro forum could help with). I believe you have coded at least one statement with SYMPUT incorrectly. Also, you are using the DO incorrectly and should be getting error messages in your log. What are those error messages?

  I would suggest that you collect this information and repost your question in the correct forum and not in the graphics forum.

Thanks!

cynthia

Tom
Super User Tom
Super User

You need to explain your algorithm.  Basically you should get rid of any attempt to loop over the data. The basic data step will take care of that for you.  You should RETAIN the values that you want to carry forward (retain) to the next observation.

Your CSV file says the name of the variable is WVAR, so I have modified the code to use that name instead of RESIDUALS.  (not sure why it would be plural anyway).

You do not define Y in your program.  I have assumed it is yet another name for the data in the CSV file.

Perhaps you want something like this?

data test;

    infile "F:\data\wvar.csv"  DSD MISSOVER firstobs=2;

    input  wvar ;

    retain sig 0;

    sig2 = 0.0000624 +  0.1438*wvar*wvar +  0.634*sig*sig;

     output;

    sig = sqrt(sig2);

run;

malakaext
Calcite | Level 5

Thank you very much. This helps a lot

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 5 replies
  • 824 views
  • 1 like
  • 4 in conversation