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

HI  I need help with a Transpose Table

data is

DAte.       Id.       machine

08/1/14.    G.         A1

08/01/14.    B.        A2

08/01/14.      L.      A3

08/01/14.      G.       A4

08/01/14.       B.        A5

08/01/14.       G.       A6

i would like to see data output like this

     Date                G.               B.               L

08/01/14.               3.                2.               1

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Since you want a dataset, expanding on stat@sas's code:

data have;

input Date $ Id $   machine $;

datalines;

08/01/14   G    A1

08/01/14   B    A2

08/01/14   L    A3

08/01/14   G    A4

08/01/14   B    A5

08/01/14   G    A6

;

proc tabulate data=have out=need (keep=date id n);

class date id machine;

table date,id=' '*n=' ';

run;

proc transpose data=need out=want (drop=_:);

  by date;

  id id;

  var n;

run;

data want;

  retain date G B L;

  set want;

run;

View solution in original post

8 REPLIES 8
Reeza
Super User

Where does the 3/2/1 come from?

stat_sas
Ammonite | Level 13

data have;

input Date $ Id $   machine $;

datalines;

08/01/14   G    A1

08/01/14   B    A2

08/01/14   L    A3

08/01/14   G    A4

08/01/14   B    A5

08/01/14   G    A6

;

proc tabulate data=have;

class date id machine;

table date,id=' '*n=' ';

run;

art297
Opal | Level 21

Since you want a dataset, expanding on stat@sas's code:

data have;

input Date $ Id $   machine $;

datalines;

08/01/14   G    A1

08/01/14   B    A2

08/01/14   L    A3

08/01/14   G    A4

08/01/14   B    A5

08/01/14   G    A6

;

proc tabulate data=have out=need (keep=date id n);

class date id machine;

table date,id=' '*n=' ';

run;

proc transpose data=need out=want (drop=_:);

  by date;

  id id;

  var n;

run;

data want;

  retain date G B L;

  set want;

run;

BETO
Fluorite | Level 6

Hi Arthur Tabacheck,

i have an additional question how can I auto append the "want" table to access table ? so once want is created it appends it to access

Thanks

art297
Opal | Level 21

I don't know what you mean by 'access' or what you want the final file to look like.

BETO
Fluorite | Level 6

HI Arthur

i would like to append it to Access  its an office program Excel has extension of .XLS  Access has .mdb 

art297
Opal | Level 21

Append it to an existing access file, or just create an access file? If it is the latter, and your site licences SAS/Access for pc file formats, look up proc export in the documentation.

Ksharp
Super User

ODBC + libname  .  check it at support.sas.com to see how to set up a ODBC connection with database .

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1269 views
  • 3 likes
  • 5 in conversation