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

Given the SAS data set WORK.INPUT:
Var1 Var2
------ -------
A one
A two
B three
C four
A five
The following SAS program is submitted:
data WORK.ONE WORK.TWO;
set WORK.INPUT;
if Var1='A' then output WORK.ONE;
output;
run;
How many observations will be in data set WORK.ONE?

I do not understand why the observation is 8. I only got 3 observations when Var1 is A. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@anming wrote:

Given the SAS data set WORK.INPUT:
Var1 Var2
------ -------
A one
A two
B three
C four
A five
The following SAS program is submitted:
data WORK.ONE WORK.TWO;
set WORK.INPUT;
if Var1='A' then output WORK.ONE;
output;
run;
How many observations will be in data set WORK.ONE?

I do not understand why the observation is 8. I only got 3 observations when Var1 is A. 

 


 

Let's see here: one line tests to see if VAR1='A' and then outputs three records to WORK.ONE. The next line outputs all records to WORK.ONE. That's 8

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

@anming wrote:

Given the SAS data set WORK.INPUT:
Var1 Var2
------ -------
A one
A two
B three
C four
A five
The following SAS program is submitted:
data WORK.ONE WORK.TWO;
set WORK.INPUT;
if Var1='A' then output WORK.ONE;
output;
run;
How many observations will be in data set WORK.ONE?

I do not understand why the observation is 8. I only got 3 observations when Var1 is A. 

 


 

Let's see here: one line tests to see if VAR1='A' and then outputs three records to WORK.ONE. The next line outputs all records to WORK.ONE. That's 8

--
Paige Miller
anming
Pyrite | Level 9
data test;
input var1$ var2$;
datalines;
A one
A Two
B Three
C four
A five
;
run;

data work.one work.two;
set test;
if var1='A' then output work.one;
output;
run;

these are test codes.

work.one has 8 observions while work.two has 5 observions. Wonderful!




Welcome to the Certification Community

 

This is a knowledge-sharing community for SAS Certified Professionals and anyone who wants to learn more about becoming SAS Certified. Ask questions and get answers fast. Share with others who are interested in certification and who are studying for certifications.To get the most from your community experience, use these getting-started resources:

Community Do's and Don'ts
How to add SAS syntax to your post
How to get fast, helpful answers

 

Why Get SAS Certified.jpg

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 3278 views
  • 5 likes
  • 2 in conversation