I am new to SAS Studio (less than a month now), What I want to do while viewing a dataset in SAS Studio is what I can do currently in the regular Display Manager. That is, to open a dataset and the click on 'Data' and then click 'Hide/Unhidle' - send all the variables over to the hidden box and I can view all the variables in alphabetical order. I can now scan down the list to view the one(s) I want and put them onto the Displayed side. This helps so much because we can have hundreds of variables in a dataset.
Is there any way to do this same thing in SAS Studio?
Thanks - Nancy
This macro may be helpful to you. It creates a view of the data with the columns alphabetically arranged:
%macro SortColumns(data=sashelp.class);
%local COLUMNS
LIBRARY
TABLE;
%*TODO: Add code to enforce valid 2-level name for DATA;
data _null_;
call symputx('LIBRARY', scan("&DATA", 1, '.'));
call symputx('TABLE', scan("&DATA", 2, '.'));
run;
proc sql noprint;
select name into: COLUMNS separated by ', '
from sashelp.vcolumn
where (libname eq upcase("&LIBRARY") and
memname eq upcase("&TABLE") and
memtype eq 'DATA')
order by upcase(name);
create view work.&TABLE as
select &COLUMNS
from &DATA;
quit;
%mend SortColumns;
When you run it from SAS Studio the output is opened in the grid view:
%SORTCOLUMNS(data=sashelp.classfit)
I tried to get this code working within a SAS Studio Task, but limitations in the task model prevented the data from being automatically opened.
Vince DelGobbo
SAS R&D
Can you provide more details on how you are able to see the columns in alphabetical order in the ViewTable Hide/Unhide window? I see them listed by their the logical position in the SAS data set.
For example, here is what I see for SASHELP.CLASS:
Vince DelGobbo
SAS R&D
I think I see how you got the alphabetical list; move all columns to hidden and then they are displayed alphabetically:
Vince DelGobbo
SAS R&D
@Vince_SAS wrote:
I think I see how you got the alphabetical list; move all columns to hidden and then they are displayed alphabetically:
Vince DelGobbo
SAS R&D
I would swear I made a variable selection tool like this with SAS/AF back around 1995 only my users had a need to select varaibles from multiple data sets as well...
If you click the double (left) arrow, they all go over to the Hidden side and are in alphabetical order now.
Now i can scan down the list and put back what I want to be displayed.
Yes - Is there any way to do that in SAS Studio in the Columns area, when you have dataset displayed? Myself and others could really use this feature.
Thanks
I do not see an easy way to do this but I am checking into it. You can drag-and-drop columns in both the navigation tree and the grid, but that is only useful if you don't have too many columns.
Vince DelGobbo
SAS R&D
Well this option would be a great enhancement to the work area of SAS Studio. If I open a dataset, it shows me the Columns and all the rows of the dataset. In the View Columns section if there was something next to the word 'Columns' that said 'Alpha' (for alphabetize) that would be a great help. I did notice that when I click on the Table Properties icon and then click on the Columns tab, I can click the 'Column Name' header and it will alphabetize the columns. That is what I need on the 'Select all' section under Columns.
Cheers!
The ability to do this is on the roadmap for a future release of SAS Studio. Attached is a sneak peek at the preliminary design.
This macro may be helpful to you. It creates a view of the data with the columns alphabetically arranged:
%macro SortColumns(data=sashelp.class);
%local COLUMNS
LIBRARY
TABLE;
%*TODO: Add code to enforce valid 2-level name for DATA;
data _null_;
call symputx('LIBRARY', scan("&DATA", 1, '.'));
call symputx('TABLE', scan("&DATA", 2, '.'));
run;
proc sql noprint;
select name into: COLUMNS separated by ', '
from sashelp.vcolumn
where (libname eq upcase("&LIBRARY") and
memname eq upcase("&TABLE") and
memtype eq 'DATA')
order by upcase(name);
create view work.&TABLE as
select &COLUMNS
from &DATA;
quit;
%mend SortColumns;
When you run it from SAS Studio the output is opened in the grid view:
%SORTCOLUMNS(data=sashelp.classfit)
I tried to get this code working within a SAS Studio Task, but limitations in the task model prevented the data from being automatically opened.
Vince DelGobbo
SAS R&D
Vince,
Thank you very much. That works perfectly for what we need. We have saved this macro to our drive and can now alphabetize any dataset in SAS Studio.
But for a future release of SAS Studio, if there is that option in the Column layout to just click a button to alphabetize the columns so the search is easier - that would be great.
SAS is the best!
Cheers,
Nancy
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.