Yes, but it doesn't make much sense.
You have a male, from country A in period 2000, who has reulsts 2,3 (no information as to what the 2/3 represents). You then have two more rows 2/2 2/2. Which is it 2/3, 2/2 or 2/2? Or was it three timepoints within period 2000? Post some test data if you want some code on how to do it directly.
@Demographer wrote:
I copied/pasted in Excel the output of a proc tabulate and then imported it in SAS. When I tried the out statement, it gaves me only one column for variables X1 X2. I suppose this was probably not the most efficient way.
PROC TABULATE can create a data set directly using OUT= on the PROC statement. This would avoid all the headaches associates with a trip to EXhell and back.
You can more easily fix your data imported from EXhell using the update trick
data haveV/view=haveV;
set have;
retain dummy 1;
run;
data want;
update haveV(obs=0 keep=dummy) haveV;
by dummy;
output;
drop dummy;
run;
Ok then, at a guess:
proc means data=have; by sex country period age_group; var thevar; where thevar="A"; output out=tab1 n=x1; run; proc means data=have; by sex country period age_group; var thevar; where thevar="B"; output out=tab2 n=x2; run; data want; merge tab1 tab2; by sex country period age_group; run;
You could also proc means to get your overall output then transpose the data up, or count it directly in a datastep etc.
I have the newest version of sas 9.4. I used to use this code but now it only works on the first retain statement. All subsequent retain statements give the error message "
retain _analyst;
------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
"
any ideas why this doesn't work now?
I tried retain _ALL_ and this doesn't help.
@today wrote:
I have the newest version of sas 9.4. I used to use this code but now it only works on the first retain statement. All subsequent retain statements give the error message "
retain _analyst;
------
180ERROR 180-322: Statement is not valid or it is used out of proper order.
"
any ideas why this doesn't work now?
I tried retain _ALL_ and this doesn't help.
Please open a new thread for your question. Include more lines from the log so that the error message is shown in context. Also use the Insert Code button so that formatting (like what word is underlined) is preserved.
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.
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.
Ready to level-up your skills? Choose your own adventure.