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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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