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

data emp;
input EMPMO $ 1-4 ENAME $ 6-11 JOB $ 13-21 MGR $ HIREDATE $ SAL $ COMM DEPTNO;
datalines;
7369 SMITH CLERK 7902 17-Dec-80 800 20
7499 ALLEN SALESMAN 7698 20-Feb-81 1600 300 30
7521 WARD SALESMAN 7698 22-Feb-81 1250 500 30
7566 JONES MANAGER 7839 02-Apr-81 2975 20
7654 MARTIN SALESMAN 7698 28-Sep-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-May-81 2850 30
7782 CLARK MANAGER 7839 09-Jun-81 2450 10
7788 SCOTT ANALYST 7566 09-Dec-81 3000 20
7839 KING PRESIDENT 17-Nov-81 5000 10
7844 TURNER SALESMAN 7698 08-Sep-81 1500 30
7876 ADAMS CLERK 7788 12-Jan-83 1100 20
7900 JAME CLERK 7698 03-Dec-81 950 30
7902 FORD ANALYST 7566 03-Dec-81 3000 20
7934 MILLER CLERK 7782 23-Jan-82 1300 10
;

proc print;
run;

 

Please arrange the code 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
data emp;
input EMPMO $ 1-4 ENAME $ 6-11 JOB $ 13-21 MGR HIREDATE :date11. SAL COMM DEPTNO;
format hiredate date11.;
infile datalines missover;
datalines;
7369 SMITH  CLERK     7902 17-Dec-80 800  20     
7499 ALLEN  SALESMAN  7698 20-Feb-81 1600 300 30 
7521 WARD   SALESMAN  7698 22-Feb-81 1250 500 30 
7566 JONES  MANAGER   7839 02-Apr-81 2975 20     
7654 MARTIN SALESMAN  7698 28-Sep-81 1250 1400 30
7698 BLAKE  MANAGER   7839 01-May-81 2850 30     
7782 CLARK  MANAGER   7839 09-Jun-81 2450 10     
7788 SCOTT  ANALYST   7566 09-Dec-81 3000 20     
7839 KING   PRESIDENT .    17-Nov-81 5000 10     
7844 TURNER SALESMAN  7698 08-Sep-81 1500 30     
7876 ADAMS  CLERK     7788 12-Jan-83 1100 20     
7900 JAME   CLERK     7698 03-Dec-81 950  30     
7902 FORD   ANALYST   7566 03-Dec-81 3000 20     
7934 MILLER CLERK     7782 23-Jan-82 1300 10     
;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20
data emp;
input EMPMO $ 1-4 ENAME $ 6-11 JOB $ 13-21 MGR HIREDATE :date11. SAL COMM DEPTNO;
format hiredate date11.;
infile datalines missover;
datalines;
7369 SMITH  CLERK     7902 17-Dec-80 800  20     
7499 ALLEN  SALESMAN  7698 20-Feb-81 1600 300 30 
7521 WARD   SALESMAN  7698 22-Feb-81 1250 500 30 
7566 JONES  MANAGER   7839 02-Apr-81 2975 20     
7654 MARTIN SALESMAN  7698 28-Sep-81 1250 1400 30
7698 BLAKE  MANAGER   7839 01-May-81 2850 30     
7782 CLARK  MANAGER   7839 09-Jun-81 2450 10     
7788 SCOTT  ANALYST   7566 09-Dec-81 3000 20     
7839 KING   PRESIDENT .    17-Nov-81 5000 10     
7844 TURNER SALESMAN  7698 08-Sep-81 1500 30     
7876 ADAMS  CLERK     7788 12-Jan-83 1100 20     
7900 JAME   CLERK     7698 03-Dec-81 950  30     
7902 FORD   ANALYST   7566 03-Dec-81 3000 20     
7934 MILLER CLERK     7782 23-Jan-82 1300 10     
;
ballardw
Super User

@Daily1 wrote:

data emp;
input EMPMO $ 1-4 ENAME $ 6-11 JOB $ 13-21 MGR $ HIREDATE $ SAL $ COMM DEPTNO;
datalines;
7369 SMITH CLERK 7902 17-Dec-80 800 20
7499 ALLEN SALESMAN 7698 20-Feb-81 1600 300 30
7521 WARD SALESMAN 7698 22-Feb-81 1250 500 30
7566 JONES MANAGER 7839 02-Apr-81 2975 20
7654 MARTIN SALESMAN 7698 28-Sep-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-May-81 2850 30
7782 CLARK MANAGER 7839 09-Jun-81 2450 10
7788 SCOTT ANALYST 7566 09-Dec-81 3000 20
7839 KING PRESIDENT 17-Nov-81 5000 10
7844 TURNER SALESMAN 7698 08-Sep-81 1500 30
7876 ADAMS CLERK 7788 12-Jan-83 1100 20
7900 JAME CLERK 7698 03-Dec-81 950 30
7902 FORD ANALYST 7566 03-Dec-81 3000 20
7934 MILLER CLERK 7782 23-Jan-82 1300 10
;

proc print;
run;

 

Please arrange the code 


Please post code into a code box opened on the forum using either the {I} or "running man" icon as @PeterClemmensen did. The main message windows on this forum will reformat pasted text to remove white space and may introduce HTML characters that are not visible. This means that what you see in the window is very likely not what was actually in your editor.

 

Good idea to learn: Read date values into SAS date values not character. Almost any manipulation will require the conversion anyway so do it when reading. This may also give you warnings about bad date values like 31-Nov-16 that you can address earlier in your process. Note that when you sort character dates they will almost NEVER appear in the order you need and will not create graphs with the proper intervals.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 2 replies
  • 302 views
  • 0 likes
  • 3 in conversation