data new;
x=10;
y=20;
output;
z=50;
output ;
x=100 ;
output ;
run;
what is the output? and how? I am not able to solve this question, can someone help me out?
thanks in advance
why not run it and let all of us know
Sorry mate!, I am not keen on doing a tutorial. You can forgive me or hate me lol. Anyway, I am sure somebody else will.
@Reeza and @MichelleHomes posted brilliant ideas/links to get you(hmm us) started in this link
Free learning resources
Have fun learning! cheers
An output statement does not change any variable values, so the previously set values persist. Only a skip into the next iteration of a data step would set variables to missing.
In the given code you have 3 outputs right then it will give you 3 observations if you have 10 output statements then it will give you 10 observations.
firs toutput iteration: x,y have values and z is missing you given output statement so it will print values for x,y and z for missing.
secondoutput iteration:z have value 50 so it will print z with 50 and you already ave x,y values so in second iteration it will print 10,20 as x,y values
third output iteration: x,y,z contain values but you again assigned with 100 x value over write and y,z values as follows.
data new;
x=10;
y=20;
output;
z=50;
output ;
x=100 ;
output ;
run;
Thanks very much.. 🙂
If that solved your problem, please mark @rajeshalwayswel as the correct answer. For future information, it is a good idea to run things, use tutorials and such like. Your question is very simple and running the code should explain what output you get.
And by all means, use more descriptive subjects for future posts. Base SAS in the Base SAS Programming community is, pardon my wording, not very intelligent.
Key ideas:
data new;
x=10; <- sets x to 10
y=20; <- sets y to 20
output; <- outputs record to data set
z=50; <- sets z to 50
output ; <- outputs record to data set. Since x/y have not been changed they remain the same
x=100 ;<- sets x to 100.
output ; <- outputs record to data set. Since y/z have not been changed they remain the same
run; <- data step boundary - all variables are reset but since no other instructions the data step is terminated.
Note that I've modified the subject line of your post to make it more descriptive. There are too many 'BASE SAS' questions.
@Ankur32 wrote:
data new;
x=10;
y=20;
output;
z=50;
output ;
x=100 ;
output ;
run;
what is the output? and how? I am not able to solve this question, can someone help me out?
thanks in advance
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!
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.