SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Madrug_
Calcite | Level 5

Prezados,

É possivel criar um campo auto numerado (IDENTITY) no SAS? Quais são as maneiras de fazer esse processo?

Ex:

CREATE TABLE exemplo

(

     COD_CLI INT IDENTITY,

     NOME VARCHAR(50),

     EMAIL VARCHAR(50)

CONSTRAINT EXEMPLO_PK_COD_CLI PRIMARY KEY(COD_CLI)

);

Obrigado pela atenção!

1 ACCEPTED SOLUTION

Accepted Solutions
TomKari
Onyx | Level 15

No, there is no identity option in SAS. Perhaps the undocumented monotonic() function could be useful

http://www.amadeus.co.uk/sas-technical-services/tips-and-techniques/sql/the-monotonic-function/.

View solution in original post

10 REPLIES 10
TomKari
Onyx | Level 15

No, there is no identity option in SAS. Perhaps the undocumented monotonic() function could be useful

http://www.amadeus.co.uk/sas-technical-services/tips-and-techniques/sql/the-monotonic-function/.

Madrug_
Calcite | Level 5

TomKari, Boa Tarde!

Eu consegui, utilizei o exemplo que você passou.

Muito Obrigado!

TomKari
Onyx | Level 15

Seja bem-vindo!

Tom

Madrug_
Calcite | Level 5

Obrigado!

Ksharp
Super User

I will not ust that undocumented function for the sake of risk. I would like use ODS.

ods listing close;

ods output sql_results=want;

proc sql number;

select * from sashelp.class;

quit;

ods listing;

Ksharp

Madrug_
Calcite | Level 5

Ksharp, Bom Dia!

Você tem um exemplo de como usar o código que você mostrou?

Ex:

PROC SQL;

     CREATE TABLE MINHA_TABELA AS

     SELECT * FROM TABELA_BASE;

RUN;

Ksharp
Super User

Please English first . I have to go to sleep now. will be back soon after a beauty sleep.

Madrug_
Calcite | Level 5

Ksharp, Good Day!

Do you have an example of how to use the code you showed?

Ex:

PROC SQL;

     CREATE TABLE MINHA_TABELA AS

     SELECT * FROM TABELA_BASE;

RUN;

PGStats
Opal | Level 21

Olá. Just follow what Ksharp wrote :

ods listing close;

ods output sql_results=MINHA_TABELA;

proc sql number;

     select * from TABELA_BASE;

quit;

ods listing;

The first statement prevents the printing of query results. The second statement directs the query result to dataset MINHA_TABELA. Option number adds a column in the query result to contain record numbers. The last statement restores normal result printing.

MINHA_TABELA will contain the same columns as TABELA_BASE with an extra column for record numbers.

PG

PG
Ksharp
Super User

PG, Thanks. So detail explanation for me  .

Ksharp

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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
  • 10 replies
  • 4397 views
  • 0 likes
  • 4 in conversation