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

I am trying to combine site and patient with a hyphen in between the two variables, using the catx function.  When I run this below, it ONLY gives me these three variables in my data, with no observations....any help is appreciated

 

data pat_info;
length site pt $ 15;
label pt_id='Site-Patient';
pt_id = catx('-',site,pt);
run;

1 ACCEPTED SOLUTION

Accepted Solutions
collinelliot
Barite | Level 11

 

So if you add the code to data step as follows, do you still have an issue?

 

data pat_info;
merge demog study;
by site pt;

label pt_id='Site-Patient';
pt_id = catx('-',site,pt);

 

run;

View solution in original post

9 REPLIES 9
collinelliot
Barite | Level 11

I don't see any kind of set statement or any other source of data.

 

You're running that code on nothing.

zjhansen30
Fluorite | Level 6

Sorry, this is my full code....I am running it after merging two data sets


proc format;
value sex
1=Female
2=Male
;
value race
1=Asian
2=Black
3=Caucasian
4=Other
;
run;

 

data study;

infile '/courses/dc4508e5ba27fe300/c_629/suppTRP-1062.txt' dlm=',' missover;


informat Site $1. Pt $2. Dosedate mmddyy10.;
input Site Pt Sex Race Dosedate Height Weight Result1 Result2 Result3;


if '01JAN1997'd <= dosedate <= '31DEC1997'd then doselot='S0576';
else if '31DEC1997'd < dosedate <= '10JAN1998'd then doselot='P1122';
else if dosedate > '10JAN1998'd then doselot='P0526';

if doselot='P0526' then do;
prot_amend='B';
if sex=1 then limit=0.03;
else if sex=2 then limit=0.02;
end;
else if doselot = 'S0576' or doselot='P1122' then do;
prot_amend='A';
limit=0.02;
end;


length site_name $30;
select(site);
when ('J') site_name='Aurora Health Associates';
when ('Q') site_name='Omaha Medical Center';
when ('R') site_name='Sherwin Heights Healthcare';
otherwise;
end;


format sex sex. race race. dosedate date.;


label site='Study Site'
pt='Patient'
dosedate='Dose Date'
doselot='Dose Lot'
prot_amend='Protocol Amendment'
limit='Lower Limit of Detection'
site_name='Site Name';
run;
libname demog '/courses/dc4508e5ba27fe300/c_629/saslib' access=readonly;
proc sort data=demog.demog1062 out=demog;
by site pt;
run;
proc sort data=study;
by site pt;
run;
data pat_info;
merge demog study;
by site pt;
run;

collinelliot
Barite | Level 11

 

So if you add the code to data step as follows, do you still have an issue?

 

data pat_info;
merge demog study;
by site pt;

label pt_id='Site-Patient';
pt_id = catx('-',site,pt);

 

run;

zjhansen30
Fluorite | Level 6

No, that fixed it.  Thank you.  I needed it in the statement.  I didnt want to put a set statement because I wanted it in the same data set, but putting that in the data step worked.  Thanks!

collinelliot
Barite | Level 11

You're welcome.

nehalsanghvi
Pyrite | Level 9

You are creating variables but not populating them, so the output dataset has no rows/data. You need to either read in the data from another dataset with a set statement, or you need to generate data in your data step. Here's your code with one row of data created in the data step:

data pat_info;
length site pt $ 15;
label pt_id='Site-Patient';
Site='Mysite';
Pt='Patname';
pt_id = catx('-',site,pt);
run;
Kurt_Bremser
Super User

You have no statement that reads data into the data step. Either use a set statement to name an existing dataset that contains site and pt, or use infile and input to read data from an external file.

Shmuel
Garnet | Level 18

1) you miss input file/dataset

2) if you want to save memory variables add output statement.

3) you didn not assign value - neither to site nor to pt variables.

4) LABEL does not assine value to a variable but to the colomn header.

 

check next example:

 

data want;

    site = 'New-York';

    pt = 123;

    lablel site_pt = 'New Var';

    site_pt = catx('-',site,pt);

    output;

run;

 

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!

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
  • 9 replies
  • 2492 views
  • 3 likes
  • 5 in conversation