CLI Examples: Reports

The following examples assume that you have already signed in to the SAS Viya platform at the command line. See Command-Line Interface: Instructions when Downloading the CLI.

Single Command Examples

Example: Show information about the report that has the ID a85235e7-fad1-4f8a-9ad9-ea0d576619e1.

sas-viya reports show-info  --id a85235e7-fad1-4f8a-9ad9-ea0d576619e1

Example: List the detailed output of all reports that were created after 2017-05-23.

sas-viya reports list --created-after 2017-05-23 --details

Example: List the reports in the SAS Viya platform system that were modified by user1.

sas-viya reports list --modified-by user1

Example: List a maximum of 50 reports that are sorted by ID and in descending order.

sas-viya reports list --details --sort-by ~id --limit 50

Example: Delete the report that has the ID a85235e7-fad1-4f8a-9ad9-ea0d576619e1.

sas-viya reports delete --id a85235e7-fad1-4f8a-9ad9-ea0d576619e1

Example: Delete the report that has the ID a85235e7-fad1-4f8a-9ad9-ea0d576619e1 without prompting the user for confirmation.

sas-viya reports delete --id a85235e7-fad1-4f8a-9ad9-ea0d576619e1 --force

Example: List all of the reports in which the name contains the specified string.

sas-viya reports list --name-contains Daily

Example: Export an entire report to a SAS report package by using the report ID and the current directory.

sas-viya reports build-package --id report_ID

Example: Export an entire report to a SAS report package called report to the directory named /home/myname.

sas-viya reports build-package --id report_ID --output-file report --output-location /home/myname

Example: Export a report package that has English text translations, but uses the French locale for data formatting and sorting.

sas-viya reports build-package --id report_ID –-locale en_US --format-locale fr_FR
Note: If you do not specify the format-locale option, then the locale is used for both text translations and data formatting and sorting. If neither is specified, then the default CLI locale is used.

Multiple Command Examples

Note: Some of these tasks must be performed by a user with administrative privileges.

Example: Update the theme that is used by a SAS Visual Analytics report. This example assumes that you already have a SAS Visual Analytics report that is using the Marine theme (the default).

1sas-viya reports themes list
2sas-viya reports themes show-info --theme-id theme_ID
3sas-viya reports list --name reportA
4sas-viya reports themes update --report-id report_ID --theme-id theme_ID
  1. List the themes that are available for SAS Visual Analytics reports, and record the ID of the theme that you want to use.

  2. Show detailed information about the identified theme for updating the report. You use the ID of the theme that was identified in the previous step.

  3. List information about reportA that you want to update, and record the ID of the report.

  4. Update the theme that is used in reportA to the theme that you identified in step 1. You use the ID of the report that you identified in the previous step.

Note: You can update a report’s theme only to a theme of type system or custom. Themes of types legacy and retired are allowed in existing reports, but cannot be used to update a theme.

Example: Export the translation worksheets for reports that need to be translated, translate the worksheets, and then import the translated worksheets into the report. Some of these tasks must be performed by a user with administrative privileges whereas the actual translation might be performed by another user.

You need to determine what reports need to be translated and what languages the reports need to be translated into. You also need to identify the base language that the reports were created in. The translation worksheets that are exported will contain strings to translate, and these strings are written in the base language that the report was created in. You must save the translation worksheets using the UTF-8 character encoding.

For this example, you learn that you need to translate the reports that were created after 01MAY2018 and whose names contain the text “VAN”. You also learn that the reports need to be translated into French, Spanish, and Japanese. You determine that the base language that the reports were written in is English. See Details for additional information about translation worksheets.

1sas-viya reports list --created-after 2018-05-01 --limit "100" --name-contains VAN
2sas-viya reports translations export --report-id report_ID 
--output-location /output-path-for-worksheet --report-locale fr-FR
3sas-viya reports translations export --report-id report_ID 
--output-location /output-path-for-worksheet --report-locale es-ES
4sas-viya reports translations export --report-id report_ID 
--output-location /output-path-for-worksheet --report-locale ja-JP
5######## LOCALE FOR THIS TRANSLATION WORKSHEET ########
fr-FR
############# BEGIN TRANSLATABLE STRINGS ##############
property.label = translated value
property1.label = translated value
property2.label = translated value


6sas-viya reports translations import 
--source-file /output-path-for-worksheet/report-name_fr-FR.reports 
7sas-viya reports translations import 
--source-file /output-path-for-worksheet/report-name_es-ES.reports
8sas-viya reports translations import 
--source-file /output-path-for-worksheet/report-name_ja-JP.reports 
  1. List the reports that were created after 01MAY2018 and whose names contain the text “VAN”. Use the limit option to specify the maximum number of reports to list. The default value is 20. To make sure that you list all the reports that were created after 01MAY2018, specify a value of 100. If you receive a message at the end of the report list that indicates that more reports are available, list the reports again with a higher value for the limit option.

    After running the code to list the reports, you find that there are four reports that you need to translate. In other words, there are four reports that were created after 01MAY2018 and whose names contain the text “VAN”. Note the report ID of each report. You will need the report ID to export the translation worksheets.

    If you do not have administrative privileges, you might be able to obtain the report ID from SAS Environment Manager.

  2. Export the translation worksheet for the first of the four reports in French (fr-FR),

  3. Export the translation worksheet for the first of the four reports in Spanish (es-ES).

  4. Export the translation worksheet for the first of the four reports in Japanese (ja-JP).

    Repeats steps 2, 3, and 4 for the second, third, and fourth reports. Be sure to update the report ID of the report in the command when you move to the second, third, and fourth report. You will issue the command a total of 12 times in this example. (There are four reports, and each report is translated into three languages). Afterward, you should have 12 translation worksheets in the location that is specified in the output location option.

    Note: If another user is performing the translation, then provide them with the translation worksheets. They can proceed with step 5.
  5. Here is an example of the lines that exist in each translation worksheet. The line following LOCALE FOR THIS TRANSLATION WORKSHEET indicates the language of the translation worksheet.

    In the French translation worksheets (report_name_fr-FR), locate the line that contains BEGIN TRANSLATABLE STRINGS. In the following lines, edit the values to the right of the equal sign (=) and provide the appropriate values, in French. Save the file.

    In the Spanish translation worksheets (report_name_es-ES), locate the line that contains BEGIN TRANSLATABLE STRINGS. In the following lines, edit the values to the right of the equal sign (=) and provide the appropriate values, in Spanish. Save the file.

    In the Japanese translation worksheets (report_name_ja-JP), locate the line that contains BEGIN TRANSLATABLE STRINGS. In the following lines, edit the values to the right of the equal sign (=) and provide the appropriate values, in Japanese. Save the file.

    Note: If the translation was performed by another user, then this user must provide the translated worksheets to the user who is performing the import.
  6. Import the French translation worksheet (report_name_fr-FR).

  7. Import the Spanish translation worksheet (report_name_es-ES).

  8. Import the Japanese translation worksheet (report_name_ja-JP).

Example: Build a SAS report package from one page of a report, where vi is the identifier for the page.

1sas-viya reports list-elements --id report_ID --pages // Determines the page IDs
2sas-viya reports build-package --id report_ID --report-elements "vi1" // One page
  1. Use the list-elements command to determine the page IDs in the report.

  2. Use the report-element option to export the information for a single page in the report. You use the page ID that was identified in the previous step.

Example: Build a SAS report package by using a comma-separated list of objects, where ve is the identifier for an object.

1sas-viya reports list-elements --id report_ID --pages // Determines the object IDs
2sas-viya reports build-package --id report_ID --report-elements "ve1,ve2,ve3" // Three objects
  1. Use the list-elements command to determine the object IDs in the report.

  2. Use the report-element option to export the information for three objects in the report. You use the objects IDs that were identified in the previous step.

Details

  • The translations export command appends the locale value that is specified as the report locale to the name of the translation report. For example, if you export a translation worksheet for reportA and specify the US English locale as the value of the report-locale option, the translation worksheet is saved in a file with the name:
    reportA_en-US.reports

    The translations export command includes a locale section in the translation worksheet that includes the locale name that you specified as the report locale. Here is an example of the locale section for the locale en-US:

    ######## LOCALE FOR THIS TRANSLATION WORKSHEET ########
    en-US
    Note: Before importing a translation worksheet, you must make sure that the language in the locale section of the worksheet matches the language in the name of the translation worksheet. The name of the file that you are importing must be appended with a locale value.
  • The character encoding of the files that contain the translation worksheets must be UTF-8.
  • The clear-results-cache command clears the results cache of report data for SAS Visual Analytics reports in the SAS Viya platform. In multi-tenancy environment releases prior to 2022.10, the command can be run only on the provider tenant, and clears the results cache for all tenants. In multi-tenancy environment releases 2022.10 and later, this command is tenant-specific. This means that it can now be run on any tenant (including the provider), and clears the results cache for only that tenant (or provider).
  • The reports CLI lists only 20 reports at a time by default. To list more than 20 reports, you can use the --limit option. To list 50 reports, enter --limit 50.
  • To specify what report number to start the list with, you can use the --start option. Suppose that you have listed the first 20 reports, and you want to list the next 20 reports, starting with report number 21, enter --start 21.

See Also

Last updated: January 22, 2026