BookmarkSubscribeRSS Feed
Amy0223
Quartz | Level 8

Hi community, I'm not sure how to answer this question. Your help is much appreciated!

 

What, if anything, is wrong with the following programs? An ellipsis (...) indicates proportions of a statement that are not germane to the exercise.

data one; infile...;
length type 2;
input lab grp m1-m50;
run;

data two; infile...;
input lab grp type mx1-mx10;
run;

data merge;
merge two one;
by lab grp;
run;

 

5 REPLIES 5
unison
Lapis Lazuli | Level 10

are 'one' and 'two' sorted by lab and grp? i.e.

 

proc sort data=one; by lab grp; run;
proc sort data=two; by lab grp; run;

*merge after here ...;

If this is not the issue, please include the log.

 

 

-unison

 

-unison
Amy0223
Quartz | Level 8

Thank you for your help! Should we put length statement in data two instead of data one because the type variable is not in data one?

length type $2;

 

SASKiwi
PROC Star

Only code statements if there is a reason for them...

r_behata
Barite | Level 11

Merge cannot be used as the name of the dataset since it is restricted keyword.

 

data merge;
merge two one;
by lab grp;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 849 views
  • 3 likes
  • 5 in conversation