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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Vince_SAS
Rhodochrosite | Level 12

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

View solution in original post

11 REPLIES 11
Vince_SAS
Rhodochrosite | Level 12

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:

 

HideUnhide.png

 

Vince DelGobbo

SAS R&D

 

Vince_SAS
Rhodochrosite | Level 12

I think I see how you got the alphabetical list; move all columns to hidden and then they are displayed alphabetically:

 

HideUnhide2.png

 

Vince DelGobbo

SAS R&D

ballardw
Super User

@Vince_SAS wrote:

I think I see how you got the alphabetical list; move all columns to hidden and then they are displayed alphabetically:

 

HideUnhide2.png

 

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...

SASHunter
Obsidian | Level 7

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.

 

 

 

SASHunter
Obsidian | Level 7

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

Vince_SAS
Rhodochrosite | Level 12

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 

SASHunter
Obsidian | Level 7

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!

samdupont
SAS Employee

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.


SASStudio_ColumnLayoutDesign.png
Vince_SAS
Rhodochrosite | Level 12

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

SASHunter
Obsidian | Level 7

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

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!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 11 replies
  • 2827 views
  • 9 likes
  • 4 in conversation