How to make a new dataset which will be having only distict values of required variables from a dataset? (using proc sql, if not possible then datastep.)
You will get the word "select" six times, the word "from" six times and the word "where" six times, plus of course the text in between six times.
That doesn't sound like what you want.
&sometext is not defined
None of this will work unless it is inside a macro, I hope you realize that
Your variables will be named var1_var, var2_var, ... (is that really what you want?) and each will be identical to the others because each time you are selecting distinct var1 from the same data set.
Not sure exactly what you want to obtain in this example ... in fact, its not even clear why you need a macro here unless the number 6 can change from run to run.
So basically, I don't understand what you are trying to do, and I think a bit of a description would be necessary before we could advise further.
Yes all this things are inside a macro. I just gave a rough example.
Bsically I want to create a dataset1 to which I want to add variables with unique values from another dataset2 with "WHERE" conditing. The WHERE condition itself gets values from a macro variable.
Perhaps you could write out a small example without macros to show me what you want to achieve. Because as stated, it seems like you are using the same var1 and dataset1 in each loop through the macro, which makes no sense, you will get the same results in each column.
OK. Explaining you otherway,
How to make a new dataset which will be having only distict values of required variables from a dataset? (using proc sql, if not possible then datastep.)
I hope this makes some sense. If not I will write steps;.
As far as I know, you'd have to create a data set separately for each required variable.
SQL doesn't really work if var1 has 12 distinct values and var2 has 5 distinct values, unless you want (possibly) 60 unique combinations of var1 and var2
May be if someone can comeup with something or using datastep.
Anyways, Thanks man.
Post some example with data.
To get distinct varibale values, you may try the simple code:
Proc sql;
select distinct var1,var2,var3,var4,var5,var6
from dset1
where condt1;
quit;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.