BookmarkSubscribeRSS Feed
fri0
Quartz | Level 8

Hi, I need to create a variable that take the lead value of another variable, I found in internet that I could use merge to do this (Also expanc but I have no license sas ets):

data work.libroper3;

merge

work.libroper2

work.libroper2(firstobs=2

keep=Fecha 'nombre comprador'n 'rut comprador'n 'nombre vendedor'n 'rut vendedor'n Instrumento Liq Cantidad Precio Tasa

Monto Valor Comisión 'T/C'n 'Codigo Folio'n Mvto 'Proc#'n Mon Bol Hora Observación Tipo Tipi Rutc Rutv SecuenciaC SecuenciaV

filtro4759 cruz1

rename=(cruz1=cruz2));

run;

In the internet example, they put "keep=x" and the X variable keeps the values and doesn't start in the second observation, but when I do this, all variables start in the second observation.

cruz2 is the variable that have the lead value of cruz1. So, I get the lead value, but rest of my variables are wrong because the start in the second observation . Anybody could help me please?

1 REPLY 1
fri0
Quartz | Level 8

I could solve it!

data work.libroper3;

merge

work.libroper2

work.libroper2(firstobs=2

keep=cruz1

rename=(cruz1=cruz2));

run;

The rest of variables are not important. with that code could keep the 1first values of all the variables and also get the lead value of cruz1 for cruz2.

The only problem is that i don't understand why, maybe it'll be helpfull if someone could explain the code.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 886 views
  • 0 likes
  • 1 in conversation