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

Hi,

I'm having two data files of two months. One is july and august.

Using proc sql I combines these two data sets

select * from

                 ( select depnto,

                             comm

                   from emp_aug13)

                  union all

                 ( select depnto,

                             comm

                   from emp_Jun13);

I got  output

deptno  Comm

  10      1000

  20      3000

  30      1500

  10       500

  20       190

  30       250

Loking for output ,

      Aug          Jul

deptno  Comm   deptno  Comm

  10     1000           10       500

  20     3000           20       190

  30     1500           30       250

Can any one share me hints to achive this.

regards,

venky

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

an example:

data one;

input id var;

cards;

1 20

2 30

3 40

;

data two;

input id var;

cards;

1 200

2 300

3 400

;

proc sql;

select one.*,two.*

  from one,two

  where one.id=two.id;

quit;

                                                 id       var        id       var

                                        

                                                 1        20         1       200

                                                 2        30         2       300

                                                 3        40         3       400

View solution in original post

4 REPLIES 4
Linlin
Lapis Lazuli | Level 10

an example:

data one;

input id var;

cards;

1 20

2 30

3 40

;

data two;

input id var;

cards;

1 200

2 300

3 400

;

proc sql;

select one.*,two.*

  from one,two

  where one.id=two.id;

quit;

                                                 id       var        id       var

                                        

                                                 1        20         1       200

                                                 2        30         2       300

                                                 3        40         3       400

LinusH
Tourmaline | Level 20

Your desired output looks like a report, not a stored data set.

Take a look at PROC REPORT, potentially PROC TABULATE.

Data never sleeps
Amarnath7
Fluorite | Level 6

use 'comm' variable as commAug ,commJun in any in the data. you can not keep two variables on the same name.

Else use proc report

proc sql;

select emp_aug13.*,emp_Jun13.*

  from emp_aug13,emp_Jun13

  where emp_aug13.depnto=emp_Jun13.depnto;

quit;

deptno  commAug commJun

  10     1000                 500

  20     3000                 190

  30     1500                  250

pallis
Fluorite | Level 6

Thank you for the help. I got the output as you suggested me.

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1261 views
  • 3 likes
  • 4 in conversation