BookmarkSubscribeRSS Feed
swayto
Fluorite | Level 6

what is wrong with this dataset, and what is the best way to code it?

     data work.comapany;

        set work.dept1 (keep=jobecode)

              work. dept2 (rename =(jcode=jobcode));

run;

3 REPLIES 3
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

you have (rename =(jcode=jobcode))

do you mean to have this  (rename =(jobcode=jcode))

 

 

Kurt_Bremser
Super User

First of all, the code is written in a very ugly way, and only its small size makes it still easy to understand, more or less.

At least try to do some consistent visual formatting, it will help you in the future.

   data work.comapany;
        set work.dept1 (keep=jobecode); /* this semicolon must not be here, as it ends the set statement prematurely */
             work. dept2 (rename =(jcode=jobcode)); /* the blank between the dot and dept2 will cause an ERROR, and the order in the rename is wrong */
run;
Tom
Super User Tom
Super User

Hard to tell if there are issues (other than obvious typos like extra semi-colon. two spellings for JOBCODE, inserted space etc) without knowing what the intent was.

 

I am not that big a fan of using KEEP=/DROP=/RENAME= dataset options instead of using the KEEP/DROP/RENAME statements, although there are some things they are best for.

 

Looks like you want to keep the variable JCODE and rename it to JOBCODE.  But then why is the target dataset named COMPANY instead of JOB (or JOBS).

 

Perhaps you meant to do something like this to create one dataset with one variable that lists all of the JOBCODE/JCODE values?

 

data jobs;
  set dept1 (keep=jobcode)
      dept2 (keep=jcode rename =(jcode=jobcode))
  ;
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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 690 views
  • 0 likes
  • 4 in conversation