BookmarkSubscribeRSS Feed
bersys02
Calcite | Level 5

Hello,

 

I have to do a freq for two variable but they are in different tables. Is there a way to do:

 

Proc freq data=table1 table2

     title "asdfg";

     table var1*var2;

run;

 

I want to do a frequency for those two variable but they are in different tables I created from the same dataset.

5 REPLIES 5
PaigeMiller
Diamond | Level 26

You have to combine the tables into a single SAS data set. You can do this in a DATA step using either MERGE or SET commands, depending on how the tables should be combined.

--
Paige Miller
bersys02
Calcite | Level 5
I created two tables from the same dataset. The first I took 4 rows and the other one is only 1 column. I can't find a way to merge them because one is numeric and the other is character. Is there a way to merge it without same ID'S OR INDEX ?
Tom
Super User Tom
Super User

@bersys02 wrote:
I created two tables from the same dataset. The first I took 4 rows and the other one is only 1 column. I can't find a way to merge them because one is numeric and the other is character. Is there a way to merge it without same ID'S OR INDEX ?

Does not make much sense. How many observations and variables did the original dataset have?  How many variables does the "first" generated dataset have?  How many observations does the "other" dataset have?  Why does whether the variable is character or numeric matter at all? PROC FREQ will not care.

 

 What did the original dataset look like? Why not just run PROC FREQ on that instead of the other datasets.  Or why not just run PROC FREQ twice, once on each of the two new datasets?

ballardw
Super User

@bersys02 wrote:
I created two tables from the same dataset. The first I took 4 rows and the other one is only 1 column. I can't find a way to merge them because one is numeric and the other is character. Is there a way to merge it without same ID'S OR INDEX ?

Subsetting your data into separate data sets is often a beginner error. Generally it is better to add a variable to indicate desired group membership and use that variable to create report tables grouped as needed.

PaigeMiller
Diamond | Level 26

@bersys02 wrote:
I created two tables from the same dataset. The first I took 4 rows and the other one is only 1 column. I can't find a way to merge them because one is numeric and the other is character. Is there a way to merge it without same ID'S OR INDEX ?

Why split the data set this way, and then try to recombine? Wouldn't it make more sense to not split the original data set and run the analysis on the original data set?

 

But in any case, we have reached the point where you need to SHOW US a portion of this data set so we can see what you are talking about.

--
Paige Miller

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1706 views
  • 0 likes
  • 4 in conversation