BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi.
I am trying to create a variable called "intersection". I would like to put two variables together to form this new variable. My variables I am looking at are "ustreet1" (aka street 1) and "ustreet2" (aka the other street in the intersection, or street 2). I would like to use proc sql to create the variable. Here is the code that I thought would work:

proc sql;
create table Columbia2 as
select distinct *, ustreet1||"_"||ustreet2 as intersection
from columbia;
quit;

I have tried this numerous different ways and only get the value from "ustreet1" in the new variable "intersection". How might I go about combining these two variable into a new one. I am sure that the code I posted is almost the right way to go about it, but I think there is something wrong with the code. Any help is greatly appreciated.
Thanks
B Message was edited by: Brad151
2 REPLIES 2
deleted_user
Not applicable
figured it out
venkatesh
Calcite | Level 5
Hi Brad...


u can go like this way also....

data columbia(drop=ustreet1 ustreet2);
input ustreet1 ustreet2;
intersection=compress(cats(ustreet1,ustreet2));
cards;
123 235
564 562
235 562
;
proc print;
run;

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
  • 2 replies
  • 571 views
  • 0 likes
  • 2 in conversation